C Programming PYQ ISRO QUIZ

Last Updated :
Discuss
Comments

Question 1

The following three 'C' language statements is equivalent to which single statement? y=y+1; z=x+y; x=x+1

  • z = x + y + 2;

  • z = (x++) + (++y);

  • z = (x++) + (y++);

  • z = (x++) + (++y) + 1;

Question 2

Write the output of the following C program

C
#include <stdio.h>

  int main (void)
  {
  int shifty;
  shifty = 0570;
  shifty = shifty >>4;
  shifty = shifty <<6;
  printf("the value of shifty is %o",shifty);
  }
  • the value of shifty is 15c0

  • the value of shifty is 4300

  • the value of shifty is 5700

  • the value of shifty is 2700

Question 3

What does the following program do when the input is unsigned 16-bit integer?

C
#include 
main( )
{
unsigned int num;
int i;
scanf (%u, &num);
for ( i = 0; i<16; i++)
{
printf (%d, (num << i & 1 << 15 ) ? 1:0);
}
}


  • It prints all even bits from num

  • It prints all odd bits from num

  • It prints binary equivalent of num

  • None of the above

Question 4

Consider the following program fragment i=6720; j=4; while (i%j)==0 { i=i/j; j=j+1; } On termination j will have the value

  • 4

  • 8

  • 9

  • 6720

Question 5

Consider the following program fragment

if(a > b)
if(b > c)
s1;
else s2;

s2 will be executed if

  • a <= b

  • b > c

  • b >= c and a <= b

  • a > b and b <= c

Question 6

The for loop

for (i=0; i<10; ++i)
printf("%d", i&1);

prints:

  • 0101010101

  • 0111111111

  • 0000000000

  • 1111111111

Question 7

What is the output of the following C code?

#include 
int main()
{
int index;
for(index=1; index<=5; index++)
{
printf("%d", index);
if (index==3)
continue;
}
}

  • 1245

  • 12345

  • 12245

  • 12354

Question 8

Consider the following C code segment:

#include 
main()
{
int i, j , x ;
scanf("%d", &x);
i = 1 ; j = 1;
while ( i< 10 ) {
j = j * i;
i = i + 1;
if (i == x) break ;
}
}

For the program fragment above, which of the following statements about the variables i and j must be true after execution of this program? [!(exclamation) sign denotes factorial in the answer]

  • ( j = (x - 1 )! ) ? (i >= x)

  • ( j = 9!) ? (i =10)

  • (( j = 10!) ? (i = 10 )) V (( j = (x - 1)!) ? (i = x ))

  • (( j = 9!) ? (i = 10)) V (( j = (x - 1)!) ? (i = x ))

Question 9

Consider the following pseudocode: 
 

x:=1;
i:=1;
while (x ? 500)
begin
x:=2x ;
i:=i+1;
end


What is the value of i at the end of the pseudocode?
 

  • 4

  • 5

  • 6

  • 7

Question 10

How many lines of output does the following C code produce? 
 

C
#include<stdio.h>
float i=2.0;
float j=1.0;
float sum = 0.0;
main()
{
    while (i/j > 0.001)
    {
        j+=j;
        sum=sum+(i/j);
        printf("%f\n", sum);
    }
}
  • 8

  • 9

  • 10

  • 11

There are 57 questions to complete.

Take a part in the ongoing discussion