You are on page 1of 5

Embedded C Questions

t
Do not turn this page until you are asked to do so.
Assessment Test ID:
Duration:10 mins
Number of Questions:10
Max Marks:10

Instructions:
1. The objective of this test is to gather information about your knowledge
in this area before/ after the training.
2. You will be provided with work sheets. Please ask if you need more.
3. Each question carries 1 mark.
4. The questions are spread across multiple pages. You have to
attempt questions on all pages to complete the test.
5. Once you complete the test, click "Submit all and finish" button.
6. After completing the test, you must return all the work sheets.
7. Switch off your cell phone now.

We wish you the very best!


Do not turn this page. Wait until you are asked to do so.

1. What is the output of this C code?


#include <stdio.h>
printf("%.0f", 2.89);
a. 2.890000
b. 2.89
c. 2
d. 3

2. What is the output of this C code?


#include <stdio.h>
void main()
{
#define max 37
printf("%d", max);
}
a) 37
b) Run time error
c) Varies
d) Depends on compiler
3. The output of the code below is
#include <stdio.h>
void m(int k)
{
printf("hi");
}
void m(double k)
{
printf("hello");
}
void main()
{

m(3);
}
a) hi
b) hello
c) Compile time error
d) Nothing
4. What is the output of this C code?
#include <stdio.h>
void main()
{
static int x;
printf("x is %d", x);
}
a) 0
b) 1
c) Junk value
d) Run time error
5.C preprocessor is conceptually the first step during compilation
a) true
b) false
c) Depends on the compiler
d) Depends on the standard
6. What is the output of this C code?
#include <stdio.h>
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int j = 10;
return &j;

}
a) 10
b) Compile time error
c) Segmentation fault/runtime crash
d) Undefined behaviour
7. Comment on the output of this C code?
#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}
a) Compile time error, declaration of a function inside main.
b) Compile time error, no definition of function fn_ptr.
c) Compile time error, illegal application of statement fn_ptr = add.
d) No Run time error, output is 5.
8. What is the output of this C code?
#include <stdio.h>
void main()
{
char *s= "hello";
char *p = s;
printf("%c\t%c", *(p + 3), s[1]);
}
a) h e
b) l l
c) l o
d) l e
9. What is the output of this C code?
#include <stdio.h>

void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}
a) Different address is printed
b) 1 2
c) Same address is printed.
d) 1 1
10. putchar(c) function/macro always outputs character c to the
a) screen
b) standard output
c) depends on the compiler
d) Depends on the standard

You might also like