C Programming Test

C Programming Test

 

What will be printed on the standard output as a result of the following code snippet?

void func()
{
static int i = 1;
int j = 1;
i++;
j++;
printf(“%d %d “,i,j);
}
void main()
{
func();
func();
func();
}

a. 2 2 2 2 2 2
b. 2 2 3 2 4 2 
c. 2 2 2 3 2 4
d. 2 2 3 3 4 4
e. None of these


Which function will convert a string into an integer?

a. int()
b. number()
c. atoi()
d. val()
e. tonum()


Which standard function is used to clear memory allocated by the malloc() function?

a. free 
b. calloc
c. delete
d. elease
e. destroy


From which of the following loop or conditional constructs, is “break” used for an early exit?

a. switch
b. fo
c. while
d. do-while
e. All of the above


What does the argv[0] represent?

a. The first command line parameter has been passed to the program
b. The program name 
c. The number of command line arguments
d. None of the above


What would be printed on the standard output as a result of the following code snippet?

#define func(t, a, b) { t temp; temp=a; a=b; b=temp; }
main()
{
             int a=3, b=4;
             float c=4.5, d = 5.99;
             func(int, a, b);
             func(float, c, d);
             printf(“%d %d “, a, b);
             printf(“%.2f %.2f\n”, c, d);
}

a. Results in Compilation Error
b. 3 4 5.99 4.50
c. 3 4 4.50 5.99
d. 4 3 5.99 4.50 
e. None of the above


What would be printed on the standard output as a result of the following code snippet?

char i = ‘A’;
char *j;
j = & i;
*j = *j + 32;
printf(“%c”,i);

a. An error will occur
b. a 
c. A
d. c


Prev1 of 6

Share This Post