0% found this document useful (0 votes)
41 views14 pages

Control Flow Statement - DPP 02 Discussion Notes

The document contains a series of C programming questions focusing on control flow statements, including switch cases, loops, and conditional expressions. Each question presents code snippets and multiple-choice answers related to the output or behavior of the code. The content is aimed at assessing understanding of control flow in C programming.

Uploaded by

aryanroy.kgp10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views14 pages

Control Flow Statement - DPP 02 Discussion Notes

The document contains a series of C programming questions focusing on control flow statements, including switch cases, loops, and conditional expressions. Each question presents code snippets and multiple-choice answers related to the output or behavior of the code. The content is aimed at assessing understanding of control flow in C programming.

Uploaded by

aryanroy.kgp10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

CS & IT

ENGINEERING
C-Programming

Control Flow Statement

DPP 02 Discussion Notes By- Abhishek Sir


Question

#Q. #include<stdio.h>
int main(){
int x = 0, y = 0, a;
a = x && ++y;
printf("%d %d", x, y);
return 0;
}

A 11 B 10

C 01 D 00
Question

#Q. #include<stdio.h>
int main(){
int x=3, y=4, z=4;
printf("%d", (z>=y>=x?100:200));
return 0 ;
}
A 100 B 200

C 0 D 1
Question

#Q. #include <stdio.h>


int main(){ int a = 80;
switch(-12%45+36/9/2*16+60) {
case 80: a = a+10;
case 5: a++;
default : a = a>>2;
}
printf (’%d", a) ;
}
A 20 B 21

C 22 D 23
Question

#Q. Question
int main()
{
int a =50;
switch(a)
{
default: a=45;
case 49: a++;
case 50: a--;
case 51: a =a+1;
}
printf("%d",a);
}
A 51 B 45

C 50 D Error
Question

#Q. Consider the following program


#include<stdio.h>
int main(){
int i= -1;
for (; ++i; i++){
printf("I am a good Student");
}
return 0 ;
}
Number of times loop is Executed
A 0 B 1

C Infinite D 2
Question

#Q. #include <stdio.h>


int main() {
int i=2+4%6+9/10;
while (i<10){
printf("I am good student");
i++;
}
return 0 ;
}
The number of times printf statement executed is _____
Question

#Q. Consider the following C program


#include <stdio.h>
int main(){
float sum = 0.0, j = 1.0, i = 2.0;
while (i/j > 0.0625){
j= j+j;
sum = sum + i/j;
printf("%f\n", sum);
}
return 0;
}
The number of times the variable sum will be printed, when the above
program is executed, is _______.
Question

#Q. #include <stdio.h>


int main() {
int i,j;
for(i =1;i<=3;i++){
for(j=1;j<=20;j++){
printf("I am a good student");
if(i==2) break;
}
}
return 0 ;
}
The number of times printf will be executed is _______.
Question

#Q. #include<stdio.h>
void main () {
int sum =0;
for (int j =1; j<=20; j++)
for (int i = 1; i <= 10; i++) {
if (i == j)
continue;
sum++;
}
printf("%d\n", sum);
}
The output of the program is _______
A 200 B 190

C 180 D 20
Question

#Q. Consider the function func shown below:


#include <stdio.h>
int main() {
int num=128;
int count = 0;
while (num/2) {
count++;
num>>= 1;
}
printf ("%d", count);
}
The value printed is __________.
Question

#Q. Consider the function func shown below:


#include <stdio.h>
int main()
{
int a=7, b=8;
while(++b & a-- )
{
printf("Hello!");
}
return 0;
}
The number of times the printf() executed is _______.
Question

#Q. Consider the function func shown below: The output is-
int main() { (a) 3 0
int a=1, b=2; (b)4 2
do (c) 3 2
{ (d) 4 1
while(b++)
{
b=b-a;
a=a+b;
}
}
while(a++<2);
printf("%d\t%d", a, b);
return 0;
}
THANK - YOU

You might also like