Search Header Logo

C Programming Coding Assessment

Authored by Jeyam Jacqueline S

Computers

1st Grade

Used 2+ times

C Programming Coding Assessment
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will be the output of the code? #include int main() { int a = 5, b = 10; a = a + b; b = b - a; a = a - b; printf("a = %d, b = %d\n", a, b); return 0; }

10

15

5

20

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How many times the while loop will get executed if a short int is 2 byte wide? #include int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; }

Infinite times

255 times

256 times

254 times

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following errors would be reported by the compiler on compiling the program given below? #include int main() { int a = 5; switch(a) { case 1: printf("First"); case 2: printf("Second"); case 3 + 2: printf("Third"); case 5: printf("Final"); break; } return 0; }

There is no break statement in each case.

Expression as in case 3 + 2 is not allowed.

Duplicate case case 5:

No error will be reported.

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Point out the error, if any in the program. #include int main() {int P = 10; switch(P) { case 10: printf("Case 1"); case 20: printf("Case 2"); break; case P: printf("Case 2"); break; } return 0; }

Error: No default value is specified

Error: Constant expression required at line case P:

Error: There is no break statement in each case.

No error will be reported.

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will be the output of the program? #include int main() { int i=2; printf("%d, %d\n", ++i, ++i); return 0; }

3, 4

4, 3

4, 4

Output may vary from compiler to compiler

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How many times the program will print "SMTEC" ? #include int main() { printf("SMTEC"); main(); return 0; }

Infinite times

32767 times

65535 times

Till stack overflows

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will be the output of the program? #include #define SQR(x)(x*x) int main() { int a, b=3; a = SQR(b+2); printf("%d\n", a); return 0; }

25

11

Error

Garbage value

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?