Programming in C

Programming in C

5 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What will be the output of the given program?

int main()
{
 printf(Hello World\\n);
 main();
 return 0;
}

  1. Infinite loop
  2. Hello World is printed 65535 times
  3. Error: Calling main() function is not allowed
  4. Error: Stack overflow
  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);
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; x=y; y=temp;
}

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

What will be the output of the given program?

int main()
{
 displayOut();
 return 0;
}
 int displayOut()
{
 printf(Hi I am Robot\\n);
}

  1. Compiles with no warning and error messages
  2. Compiles with warning: conflicting types for dispalyOut
  3. Does not compile, gives error : dispalyOut not declared
  4. Compiles but throws error while linking
  5. Hi I am Robot
Question 4 Multiple Choice (Single Answer)

Which of the following statements about the given program is correct?

int fun(int, int);
int main()
{    
int x=fun(2,3);
}
fun (int x, int y) //Line 7
{     
int x;         //Line 8     
x = 20;     
return x;      //Line 10
}

  1. Line 7 should be like => int fun (int x, int y)
  2. At line 8 error: ‘x’ redeclared as different kind of symbol
  3. At line 10 error : return of local variable ‘x’
  4. No error
  5. None of the above
Question 5 Multiple Choice (Single Answer)

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

Int main()
{   
printf(Hello from main,);     
int inside()   
{      
printf(inside,);        
int deepinside()      
{        
printf(and deepinside function\\n);      
}     
}
}

  1. Hello from main, inside, and deepinside function
  2. Hello from main, inside
  3. Hello from main, and deepinside function, inside
  4. Error in the program
  5. None of the above