Friday, February 26, 2016

Learn C from home

Learn c language well and get your dream job...
To learn "c" from home thru online
contact
cithilagam@gmail.com



C Questions with Answers:
1. The Case keyword is followed by?
A. Float values
B. Character values
C. Integer values
D. Both b&c
Ans: You know that “case” keyword is used in switch statement for multiple branching.
In that we can use integer and character values.Float values are not allowed.
Ex..
case 1:
case ‘a’:
like this..
So the answer i D. (Both b &c).(i.e Character & Integer values).

2. How to make an infinity loop in C?
Ans:
Write a code like this in a c pgm.
{loop:
goto loop
}
If we didn’t give any conditional statement to terminate an loop, it will go infinitely.is it? so the above coding is the ans.

Write the o/p.
Ex1:
#define SQR(x) x * x

main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above

Ans:
Here you can rewrite the code as 225/15 *15.
 15 * 15 =225 it is the ans.


Ex:2
main()
{
int i = 0xff ;
printf("%d", i<<2);
}


a. 4
b. 512
c. 1020
d. 1024


Ans:
Here the left shift operator causes all the bits in the first operand to be shifted to the left by the number of positions indicated by the second operand.(here i=>1st operand, 2 => 2nd operand). Here the bits are represented..(4 bit for 1 digit..i.e f => 1 1 1 1)
1 1 1 1 1 1 1 1
When shited leftwise(2 times).

1 1 1 1 1 1 1 1 0 0


this can be represented by
3 15 12 is it.. i.e in hexadecimal form 3fc.
convert to decimal form..
3 * 16**2 + 15 * 16**1+12 *16**0 = 1020 this is the answer.(Ans.C)

No comments: