# Conditional Statement

 Question 1
Consider the following ANSI C program.
 #include < stdio.h >
int main()
{
int i, j, count;
count=0;
i=0;
for (j=-3; j < =3; j++)
{
if (( j > = 0) && (i++))
count = count + j;
}
count = count +i;
printf("%d", count);
return 0;
}
Which one of the following options is correct?
 A The program will not compile successfully B The program will compile successfully and output 10 when executed C The program will compile successfully and output 8 when executed D The program will compile successfully and output 13 when executed
GATE CSE 2021 SET-1   C Programming
Question 1 Explanation:
 Question 2
What is the output of tho following program?
 main(){
int x=2, y=5;
if(x < y) return (x=x+y);
else printf("z1");
printf("z2");
}
 A z2 B z1z2 C Compilation error D None of these
ISRO CSE 2018   C Programming
Question 2 Explanation:
 Question 3
Assume A and B are non-zero positive integers. The following code segment:
 while(A!=B){
if(A > B)
A -= B;
else
B -= A;
}
cout << A; // printing the value of A
 A Computes the LCM of two numbers B Divides the larger number by the smaller number C Computes the GCD of two numbers D Finds the smaller of two numbers
ISRO CSE 2018   C Programming
Question 3 Explanation:
 Question 4
What will be the output of the following C code?
 #include < stdio.h >
main()
{
int i;
for(i=0;i<5;i++)
{
int i=10;
printf("%d" , i);
i++;
}
return 0;
}

 A 10 11 12 13 14 B 10 10 10 10 10 C 0 1 2 3 4 D Compilation error
ISRO CSE 2017   C Programming
Question 4 Explanation:
 Question 5
Consider the following segment of C-code:
int j, n;
j = 1;
while (j <= n)
j = j * 2;
The number of comparisons made in the execution of the loop for any n>0 is:
 A $\lceil \log_2n \rceil +1$ B n C $\lceil \log_2n \rceil$ D $\lfloor \log_2n \rfloor +1$
ISRO CSE 2016   C Programming
Question 5 Explanation:
 Question 6
Consider the following program fragment
 if(a > b)  if(b > c)     s1;  else s2;
s2 will be executed if
 A a <= b B b > c C b >= c and a <= b D a > b and b <= c
ISRO CSE 2015   C Programming
Question 6 Explanation:
 Question 7
Consider the following C program:
#include < stdio.h >
int main( )
{
int i, j, k = 0;
j = 2 * 3 / 4 + 2.0 / 5 + 8 / 5;
k -=  --j;
for(i = 0; i < 5; i++)
{
switch(i + k)
{
case 1:
case 2: printf("n%d", i+k);
case 3: printf("n%d", i+k);
default: printf("n%d", i+k);
}
}
return 0;
}
The number of times printf statement is executed is ________.
 A 10 B 5 C 7 D 8
GATE CSE 2015 SET-3   C Programming
Question 7 Explanation:
 Question 8
Consider the C program below.

#include < stdio.h >
int *A, stkTop;
int stkFunc(int opcode, int val)
{
static int size=0, stkTop=0;
switch (opcode) {
case -1: size = val; break;
case 0: if (stkTop < size) A[stkTop++] = val; break;
default: if (stkTop) return A[--stkTop];
}
return -1;
}
int main()
{
int B; A = B; stkTop = -1;
stkFunc (-1, 10);
stkFunc ( 0, 5);
stkFunc ( 0, 10);
printf ("%d\n", stkFunc(1, 0) + stkFunc(1, 0));
}
The value printed by the above program is __________.
 A 5 B 10 C 15 D 20
GATE CSE 2015 SET-2   C Programming
Question 8 Explanation:
 Question 9
What will be the output of the following C program segment?
 char inChar = 'A' ;
switch ( inChar ) {
case 'A' : printf ("Choice A\ n") ;
case 'B' :
case 'C' : printf ("Choice B") ;
case 'D' :
case 'E' :
default : printf ( " No Choice" ) ; } 
 A No Choice B Choice A C Choice A Choice B No Choice D Program gives no output as it is erroneous
GATE CSE 2012   C Programming
Question 9 Explanation:
 Question 10
What is the output of the following C code?
#include < stdio.h >
int main()
{
int index;
for(index=1; index<=5; index++)
{
printf("%d", index);
if (index==3)
continue;
}
}

 A 1245 B 12345 C 12245 D 12354
ISRO CSE 2011   C Programming
Question 10 Explanation:
There are 10 questions to complete.

### 4 thoughts on “Conditional Statement”

1. Question number 16 of conditional statements of c programming correct option is D.

• Thank You PRAFUL SAMBHAJI RANE,

2. •  