output question based on c

Question 1
Output of following program?
#include <stdio.h>
int main()
{
    int i = 5;
    printf("%d %d %d", i++, i++, i++);
    return 0;
}
A
7 6 5
B
5 6 7
C
7 7 7
D
Compiler Dependent

Question 2
In C, parameters are always
A
Passed by value
B
Passed by reference
C
Non-pointer variables are passed by value and pointers are passed by reference
D
Passed by value result

Question 3
Which of the following is true about return type of functions in C?
A
Functions can return any type
B
Functions can return any type except array and functions
C
Functions can return any type except array, functions and union
D
Functions can return any type except array, functions, function pointer and union
Question 4
#include <stdio.h>
int main()
{
  printf("%d", main); 
  return 0;
}
A
Address of main function
B
Compiler Error
C
Runtime Error
D
Some random value
Question 5
Output?
#include <stdio.h>
 
int main()
{
    int (*ptr)(int ) = fun;
    (*ptr)(3);
    return 0;
}
 
int fun(int n)
{
  for(;n > 0; n--)
    printf("GeeksQuiz ");
  return 0;
}
A
GeeksQuiz GeeksQuiz GeeksQuiz
B
GeeksQuiz GeeksQuiz
C
Compiler Error
D
Runtime Error


Question 6
Output of following program?
#include<stdio.h>
 
void dynamic(int s, ...)
{
    printf("%d ", s);
}
 
int main()
{
    dynamic(2, 4, 6, 8);
    dynamic(3, 6, 9);
    return 0;
}
A
2 3
B
Compiler Error
C
4 3
D
3 2

Question 7
Predict the output?
#include <stdio.h>
int main()
{
    void demo();
    void (*fun)();
    fun = demo;
    (*fun)();
    fun();
    return 0;
}
 
void demo()
{
    printf("GeeksQuiz ");
}
A
GeeksQuiz
B
GeeksQuiz GeeksQuiz
C
Compiler Error
D
Blank Screen
Question 8
What is the meaning of using extern before function declaration? For example following function sum is made extern
extern int sum(int x, int y, int z)
{
    return (x + y + z);
}
A
Function is made globally available
B
extern means nothing, sum() is same without extern keyword.
C
Function need not to be declared before its use
D
Function is made local to the file.

Question 9
What is the meaning of using static before function declaration? For example following function sum is made static
static int sum(int x, int y, int z)
{
    return (x + y + z);
}
A
Static means nothing, sum() is same without static keyword.
B
Function need not to be declared before its use
C
Access to static functions is restricted to the file where they are declared
D
Static functions are made inline
 


Question 10
In C, what is the meaning of following function prototype with empty parameter list
void fun()
{
   /* .... */
}
A
Function can only be called without any parameter
B
Function can be called with any number of parameters of any types
C
Function can be called with any number of integer parameters.
D
Function can be called with one integer parameter

0 Comments:

Post a Comment