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?The program will not compile successfully | |
The program will compile successfully and output 10 when executed | |
The program will compile successfully and output 8 when executed | |
The program will compile successfully and output 13 when executed |
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");
}
z2 | |
z1z2 | |
Compilation error | |
None of these |
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
Computes the LCM of two numbers | |
Divides the larger number by the smaller number | |
Computes the GCD of two numbers | |
Finds the smaller of two numbers |
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;
}
10 11 12 13 14 | |
10 10 10 10 10 | |
0 1 2 3 4 | |
Compilation error |
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:\lceil \log_2n \rceil +1 | |
n | |
\lceil \log_2n \rceil | |
\lfloor \log_2n \rfloor +1 |
Question 5 Explanation:
Question 6 |
Consider the following program fragment
if(a > b) if(b > c) s1; else s2;
s2 will be executed ifa <= b | |
b > c | |
b >= c and a <= b | |
a > b and b <= c |
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 ________.10 | |
5 | |
7 | |
8 |
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[20]; 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 __________.5 | |
10 | |
15 | |
20 |
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" ) ; }
No Choice | |
Choice A | |
Choice A Choice B No Choice | |
Program gives no output as it is erroneous |
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;
}
}
1245 | |
12345 | |
12245 | |
12354 |
Question 10 Explanation:
There are 10 questions to complete.
Question number 16 of conditional statements of c programming correct option is D.
Your correct answer is b which is wrong. Please check 🙏🙏
Thank You PRAFUL SAMBHAJI RANE,
We have updated the answer.
Question number 3 is incomplete.
Thank You Rahul,
We have updated the question.