Q. What is the output of this program?

Code:
main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf(“%d”,xyz.i);
}
  • (A) 10
  • (B) program will not compile
  • (C) address of I
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (A) 10

Q. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

  • (A) The array size would appropriately grow.
  • (B) The program may crash if some important data gets overwritten.
  • (C) The compiler would report an error.
  • (D) The element will be set to 0.
πŸ’¬ Discuss
βœ… Correct Answer: (B) The program may crash if some important data gets overwritten.

Q. What would be the output of the following program?

Code:
#include
main()
{
char str[]=”S\065AB”;
printf(“n%d”, sizeof(str));
}
  • (A) 5
  • (B) 6
  • (C) 7
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 6

Q. What will be the value of `a` after the following code is executed?

Code:
define square(x) x*x
a = square(2+3)
  • (A) 10
  • (B) 11
  • (C) 13
  • (D) 25
πŸ’¬ Discuss
βœ… Correct Answer: (B) 11

Q. With what do you replace the ???? to make the function shown below return the correct answer?

Code:
long factorial (long x)
{
????
return x * factorial(x – 1);
}
  • (A) if (x == 0) return 0;
  • (B) return 1;
  • (C) if (x >= 2) return 2;
  • (D) if (x <= 1) return 1;
πŸ’¬ Discuss
βœ… Correct Answer: (D) if (x <= 1) return 1;

Q. What is printed when the sample code is executed?

Code:
int y[4] = {6, 7, 8, 9};
int *ptr = y + 2; printf(“%dn”, ptr[ 1 ] );
  • (A) 6
  • (B) 7
  • (C) 8
  • (D) 9
πŸ’¬ Discuss
βœ… Correct Answer: (D) 9

Q. What will be the output of below code?

Code:
int i = 4;
switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;

case 8:
i += 5;
break;
}
printf(“i = %dn”, i);
  • (A) i = 5
  • (B) i = 8
  • (C) i = 9
  • (D) i = 10
πŸ’¬ Discuss
βœ… Correct Answer: (A) i = 5

Q. What will be output if you will compile and execute the following c code?

Code:
void main()
{
if(printf(“cquestionbank”))
printf(“I know c”);
else
printf(“I know c++”);
}
  • (A) I know c
  • (B) I know c++
  • (C) cquestionbankI know c
  • (D) cquestionbankI know c++
πŸ’¬ Discuss
βœ… Correct Answer: (C) cquestionbankI know c

Q. What will be output if you will compile and execute the following c code?

Code:
#define call(x) #x
void main(){
printf(“%s”,call(c/c++));
}
  • (A) c
  • (B) c++
  • (C) #c/c++
  • (D) c/c++
πŸ’¬ Discuss
βœ… Correct Answer: (D) c/c++

Q. What will be output if you will compile and execute the following c code?

Code:
void main(){
int a=25;
clrscr();
printf(“%o %x”,a,A.;
getch();
}
  • (A) 31 19
  • (B) 12 42
  • (C) 025 0x25
  • (D) 25 25
πŸ’¬ Discuss
βœ… Correct Answer: (A) 31 19