First time user?    |

#### Select chapter

functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
trees (1.papers)
basics (5.papers)
Hide

# c basics interview questions and answers

1
`Which of the below are not valid in C?`
1. `class aClass{public: int x;};`
2. `/* Comment A */`
3. `char ar=253;`
4. `none of the above`
Share
2
```what does below code do in c?

a ^= b^ = a^ = b; ```
1. `it will swap the values of a and b`
2. `it will swap addresses of a and b`
3. `it doubles the values of a and b`
4. `it jumbles values of a and b, but finally it will not be swapped.`
Share
3
`Write a program to print hello world with out using semicolon, by using a c program.`
1. ```main()
{
if(printf(”Hello world”));
}```
2. ```main()
{
printf(”Hello world”)
}```
3. ```main()
{
if(printf(”Hello world”))
{
}
}```
4. `It is not possible to write c program with out a semicolor ;`
Share
4
```Example of for loop and arrays in c:

What is below program doing?

int hack(int n)
{
int f[n+1];
f[1] = f[2] = 1;

printf("\nf[1] = %d", f[1]);
printf("\nf[2] = %d", f[2]);
for (int i = 3; i <= n; i++)
{
f[i] = f[i-1] + f[i-2];
printf("\nf[%d] = [%d]",i,f[i]);
}
return f[n];
}```
1. `This is a recursive way to find fibonacci series.`
2. `this program will end up in infinite for loop and crashes.`
3. `This is an iterative way to find the factorial of a given number.`
4. `an iterative way to generate fibonacci numbers and also return the nth number.`
Share
5
`How to swap 2 variables with out using temporary variable by using a c program?`
1. `a=a+b; b=a-b; a=a-b;`
2. `a^ = b^ = a^ = b; We can use ^ (x-or) symbol and do some trick to swap two values. But this technique won't work with some compiler implementations.`
3. `both are correct`
4. `both are wrong`
Share
6
```while loop with example in c:

What is the output of below program? what is this program doing?

int main()
{
int num = 15;
int r=0;
while(num)
{
r=r*10+num%10;
num=num/10;
}
printf(" %d",r);

return 0;
}```
1. `This is the code to reverse a given number, output will be 51 for this program.`
2. `this code finds whether the given number is divisible by 10 or not. it prints 15.`
3. `this code finds whether the given number is multiple of 10 or not. it prints 0.`
4. `this code finds whether the given number is divisible by 10 or not. it prints 51.`
Share
Share
8
```Can the following function be declared as inline?

int f(int x)
{
return x++;
}```
1. `yes`
2. `no`
3. `depends on compiler`
4. `it is compile time error`
Share
Share
Share
Share
12
`What does 7/9*9 equals in c?`
1. `1`
2. `0.08642`
3. `0`
4. `none of the above`
Share
13
```Evaluate the following statement in c:

!(1&&0||!1)```
1. `TRUE`
2. `FALSE`
3. `invalid expression`
4. `depends on the compiler`
Share
14
`What is the maximum value of an unsigned char in c?`
1. `255`
2. `128`
3. `32786`
4. `it depends`
Share
Share
Share
Share
18
```What does below code will do?

int a=5 ,b=7,c ;
c=a+++b ;```
1. `a=5;b=7;c=12`
2. `a=6;b=7;c=12`
3. `a=6;b=7;c=13`
4. `error`
Share
19
```Is the following c code correct?

const int i=9;
int &r=i;```
1. `yes`
2. `no`
3. `depends on compiler`
4. `compile time error`
Share
20
```What is the mistake with below c program? If there is no mistake, then what is the output?

main()
{
int i=10;
printf("%d",(i++*i++))
}```
1. `Even though it works, it is not a proper way to use same variable which varies its value in the same expression.`
2. `122`
3. `100`
4. `120`