C LANGUAGE QUIZ 7

4
Created on By Sirjana GhimireAcharya

C Language Quiz 7

1 / 10

1. What is the value of 'grade' after the switch statement is executed?

 

marks = 80;

switch (marks)

{

case 60:

grade = 'C';

break;

case 75:

grade = 'B';

break;

case 80:

grade = 'A';

break;

default:

grade = 'E';

}

 

 

2 / 10

2. What is the output of the following program?

void abc(int a){
++a;
printf("%d",a);
}
void main(){
int a=10;
abc(++a);
abc(a++);
printf("%d",a);
}

3 / 10

3. Suppose a,b,c are integer variables with values 5,6,7 respectively. What is the value of the expression:
!((b+c)>(a+10))

4 / 10

4. What will be output of the following c program?
#include "stdio.h"
int main()
{
int _ = 5;
int __ = 10;
int ___;
___ = _ + __;
printf("%i", ___);
return 0;
}

5 / 10

5.Consider the following translation unit consisting of a global variable declaration:

struct foo x;

struct foo { int i; }

At the point of the declaration of variable x the structure type foo is incomplete. Thus the size is unknown. Only later on in the translation unit the type is completed. Is this translation unit legal?

 

 

6 / 10

6.Consider the following function where the type of parameter a as well as of local variable b is an array of 42 integers.

bool foo(int a[42]) {

int b[42];

return sizeof(a) == sizeof(b);

}

 

7 / 10

7. Find the output of the following program.

void main(){

int i = 01289;

printf("%d", i);

}

8 / 10

8.Assuming a short is two bytes long, what will be printed by the below code?

short exmarray[4] [3] = { {1}, {2, 3},  {4, 5, 6}};

printf("%d", sizeof(exmarray));

 

9 / 10

9. What is the output of the following program?

void xyz(int p1, int *p2){

++p1;

++*p2;

printf("%d%d",p1,*p2);

}

void main(){

int a=10;

xyz(a++,++*(&a));

xyz(a++,++*(&a));

printf("%d",a);

}

 

10 / 10

10.What is the output of following program?

void e1(){

static int a=5;

++a;

printf("%d",a);

}

main(){

e1();

e1();

}

 

Your score is

The average score is 8%

0%