Monday, December 1, 2008

Placement C Progrmming Language Question with Solution

1)
1. const char *a;
2. char* const a; 
3. char const *a;
-Differentiate the above declarations.


Answer:
1. 'const' applies to char * rather than 'a' ( pointer to a constant char )
*a='F'      : illegal
a="Hi"      : legal


2. 'const' applies to 'a'  rather than to the value of a (constant pointer to char )
*a='F'       : legal
a="Hi"       : illegal

3. Same as 1.



2)
main()
{
int i=5,j=10;
i=i&=j&&10;
printf("%d %d",i,j);
}


Answer:-
1 10


Explanation:
The expression can be written as i=(i&=(j&&10)); The inner expression (j&&10) evaluates to 1 because j==10. i is 5. i = 5&1 is 1. Hence the result. 

3)
main()
{
int i=4,j=7;
j = j || i++ && printf("YOU CAN");
printf("%d %d", i, j);
}

Answer:
4 1 

Explanation:
The boolean expression needs to be evaluated only till the truth value of the expression is not known. j is not equal to zero itself means that the expression’s truth value is 1. Because it is followed by || and true || (anything) => true where (anything) will not be evaluated. So the remaining expression is not evaluated and so the value of i remains the same.
Similarly when && operator is involved in an expression, when any of the operands become false, the whole expression’s truth value becomes false and hence the remaining expression will not be evaluated.     
false && (anything) => false where (anything) will not be evaluated.

4)
main()
{
register int a=2;
printf("Address of a = %d",&a);
printf("Value of a   = %d",a);
}

Answer:
Compier Error: '&' on register variable

Rule to Remember:
& (address of ) operator cannot be applied on register variables.
5)
main()
{
float i=1.5;
switch(i)
{
case 1: printf("1");
case 2: printf("2");
default : printf("0");
}
}


Answer:
Compiler Error: switch expression not integral


Explanation:
Switch statements can be applied only to integral types.


ALL PLACEMENT TECHNICAL INTERVIEW QUESTION  BANCK   

1Technical /logical interview questions and solution in C language |2Technical / logical interview questions in C language |3C programming Language Technical Questions And Answers |4C Language Technical Questions And Answers |5C Language Technical Interview Questions And solution |6C Language Technical Interview Questions And Answers |7C Language Interview Questions And Solution |8online Placement Question of c programming languge |9online placement c programming question|10online test of c programming languge|11placement c programming quiz with solution |12c programming quiz with solution |13C programming languge quiz with solution |14C quiz with solution |15C languge quiz with solution  |16C programming quiz with solution |17questions with answer in C programming language|18Technical questions with solution in C programming language  |19Technical questions with answer in C programming language |20placement Question and answer in Simple C Language |21Simple C Language placement Question and answer22Simple C programming Question and answer |23Simple C programming Question and answer |24Simple C Language Question and answer |25c progrmming Interview question with solution  |26Technical placement question with solution in c progrmming |27placement c progrmming Question with Answer  |28c progrmming placement question with solution  |29 placement c progrmming languge question with Answer |30placement c progrmming languge question with solution  |31c progrmming languge placement question with solution  |32c languge placement question with solution |33placement c programming languge problem with solution  |34c programming languge placement problem with solution  |35c language placement problem with solution  |36Placement c languge problem with solution  |37c language problem with answer  |38c language problem with solution  |

No comments:

Post a Comment

Thanks to given comments.......

My Blog List