Technical Interview: Computer Science and Engineering: C Programming

Doorsteptutor material for competitive exams is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of your exam.

Computer Science and Engineering

C Programming

1) Write a program to print?

⚹⚹ ⚹⚹ ⚹

⚹⚹ ⚹⚹

⚹⚹ ⚹

⚹⚹

2) When should a type cast be used?

3) What are the different data types?

4) What is the output of the below program?

#include < stdio. h >

int main () {

char a = ‘a.’

printf ( “size of variable a is % d ⧵n,” sizeof (c) ) ,

printf ( “size of a is % d” , sizeof ( ‘a’ ) ) ,

return 0,

}

5) Does the below program run successfully?

#include < stdio. h >

int main () {

int const a = 1,

a = 2,

}

6) What is difference between i ++ and ++ i?

7) What is the output of the below program?

include < stdio. h >

int main ()

{

int m = 40, n = 20, o = 20, p = 30,

if (m > n && m! = 0)

printf ( “&& Operator: Both conditions are true⧵n” ) ,

if (o > p || p! = 20)

printf ( “|| Operator: Only one condition is true⧵n” ) ,

if (! (m > n && m! = 0) )

printf ( “! Operator: Both conditions are true⧵n” ) ,

else

printf ( “! Operator: Both conditions are true. But stats are inverted as false⧵n” ) ,

}

8) What is the output of the following code?

#include < stdio. h >

void main () {

int check = 2,

switch (check) {

case 1: printf ( “Infosys” ) ,

case 2: printf ( “Gail” ) ,

case 3: printf ( “L&T” ) ,

default: printf ( “AirIndia” ) ,

}

}

9) What is the difference between

a. parameter passed by reference

b. parameter passed by value

10) In the code below, which variable has the largest scope?

include < stdio. h >

int b,

int main ()

{

int c,

return 0,

}

int a,

11) Can we convert int to double? If yes, give an example expression?

12) What is the difference between string and character arrays?

13) Define structure and give an example?

14) What does static variable mean?

15) What is the benefit of using ‘const’ ?

16) What is recursive function? Write a program of Fibonacci series using recursive function?

17) Give a syntax of declaring array?

18) Write a program to print every element of dimensional array?

19) What is a pointer?

20) How do you use a pointer to a function?

21) What do you mean by inline function?

22) What are the different storage classes in C?

23) What is the difference between printf () and sprintf () ?

24) Does there exist any other function which can be used to convert an integer/float to a string?

25) Can a variable be both constant and volatile?

26) Advantages of a macro over a function?

27) Which bit wise operator is suitable for checking whether a bit is on or off?

28) When should the volatile modifier be used?

29) const char ⚹ p, char const ⚹ p

What is the difference between the above two?

30) What is output of below program?

#include < stdio. h >

int main () }

int a = 500,

char ⚹ ptr = (char ⚹) &a,

printf ( “% d⧵n,” ⚹ ptr) ,

printf ( “% d,” ⚹+ + ptr) ,

return 0,

}

31) void main ()

{

struct country {

char c; float d,

} ;

Struct world {

int a [3] ; char b,

struct country state,

} ;

struct world st = { {1,2, 3} , ‘I’ , ‘r’ , 2.4} ,

clrsr () ,

printf ( “% d⧵t % c⧵t %% f,” st. a [1] , st. b,

st. state. c, st. state. d) ,

getch () ,

}

32) Which of the following operation are not allowed in structure?

a) Dynamic allocation of memory for structure

b) Pointer to a variable of same structure

c) Typecasting of structure

d) All of the mentioned

33) #include < stdio. h >

int main () {

int p = 5, q = 10,

swap (&p, &q) ,

printf ( “% d % d,” q, q) ,

return 0,

}

void swap (int ⚹ a, int ⚹ b) {

int ⚹ temp,

⚹ temp =⚹ a,

⚹ a =⚹ b,

⚹ b =⚹ temp,

}

Which one of the below parameters passing does the swap method is used?

A) Pass by Value

B) Pass by Reference

34) What does realloc () and malloc () function does and what is fundamental difference between both?

35) What is header file and what directive is used for declaring header file?

36) List out the header files where printf, scanf, count and cin are declared?

Developed by: