Programming in C

Test your knowledge of C programming fundamentals including variables, pointers, functions, and storage classes.

5 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Find out the output of the given program or error if any.

static int i=10;
int main()
{     
i=25;       // line 4     
printf(%d,i);     
return 0;
}

  1. 10
  2. 25
  3. Garbage value
  4. Error in the program
  5. None of these
Question 2 Multiple Choice (Single Answer)

Find out the output of the given program or error if any.

int main()
{   
void swap (int*,int*); //Line 4   
int a=10,b=20;   
swap(&a,&b);        //Line 6   
printf(%d,%d,a,b);
 getch(); 
}  
void swap( int* x, int* y) //Line 9
{   
int temp=*x;    //Line 10       
*x=*y;            //Line 11       
*y=temp;    //line 12
}

  1. 10, 20
  2. 20, 10
  3. 20, 20
  4. 10, 10
  5. Error in the program
Question 3 Multiple Choice (Single Answer)

What will be the output of the given program or find out the error if any?

int main()
{    
float  x=fun(2,3);    
printf(%f,x);
}
int fun (int x,float y) //Line 7
{      
x = 20.9;   //Line 9      
return x;
}

  1. 20.99000
  2. 20.00000
  3. 20
  4. 20.9
  5. Error in the program
Question 4 Multiple Choice (Single Answer)

Find out the output of the given program or error if any.

static int i=10;  
i=20;             
 int main()
{     
printf(%d,i);     
return 0;
}

  1. 10
  2. 20
  3. 0
  4. Garbage value
  5. Compilation error
Question 5 Multiple Choice (Single Answer)

Find out the output of the given program or error if any.

int main()
{         
register int n;        
int i;         
printf(Enter the no. of loops to run:);         
scanf(%d,&n);         
for (i=0;i < n;i++)         
{                 
printf(%d\\n,i);         
}
}

  1. Prints 1 to n
  2. Prints 1 to n-1
  3. Prints n
  4. Infinite loop
  5. Compilation error