Search Placementyogi.com
 

C Basics Objective Questions and Answers

  :: Topics ::

1

What is the output of:

#include<stdio.h>
int main()
{
	int x=40;
	{
		int x=20;
		printf("%d",x);
	}
	printf("%d",x);
	return 0;
}
A.

40 40

B.

20 40

C.

40 20

D.

Compilation Error

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

The variable declared inside the  inner block replaces the x declared in the outer block, hence it prints 20 at 1st printf.

When the inner block ends, the scope of inner x also ends and hence the value of x becomes 40 in the outer block.

 
2

What is the output of the following program:

void main( )
{
int i = 2, j = 3, k, l ;
float a, b ;
k = i / j * j ;
l = j / i * i ;
a = i / j * j ;
b = j / i * i ;
printf( "%d %d %f %f", k, l, a, b ) ;
}
A.

3 3 2 2

B.

3 3 0 2.000000

C.

3 2 0.000000 3.000000

D.

0 2 0.000000 2.000000

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

RHS is evaluated first and then the value is promoted to float, float arithmetic is not used here as there is no variable on the RHS that is float.
The Float is printed with decimal followed by 6 zeros.

 
3

What is the output of:

main( )
{
int a, b ;
a = -3 - - 3 ;
b = -3 - - ( - 3 ) ;
printf ( "a = %d b = %d", a, b ) ;
}
A.

-3 3

B.

-6 0

C.

0 -6

D.

None of the Above

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

-3 - -3= -3 + 3 = 0
-3 --(-3)= -3 - 3 = -6

 
4

C language was developed by?

A.

Dennis Richie

B.

Martin Richards

C.

Bill Gates

D.

Ken Thompson

See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation

No Explanation needed !!!

 
5

A character variable can store  x characters at a time:

A.

1 character

B.

8 character

C.

256 character

D.

None of the above

See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation

A character variable is of 1 byte length and can store just 1 character at a time

 
 


Hide Page Information