Monday, December 1, 2008

C PROGRAMMING language PROBLEM with ANSWERS

1)
void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(“%c   %d \n“, ch, ch);
}

Answer: 
Implementaion dependent

Explanation:
The char type may be signed or unsigned by default. If it is signed then ch++ is executed after ch reaches 127 and rotates back to -128. Thus ch is always smaller than 127.


2)
         Is this code legal?
         int *ptr; 
           ptr = (int *) 0x400; 

Answer: 
Yes

Explanation:
The pointer ptr will point at the integer in the memory location 0x400. 

3)
 main()
{
char a[4]="HELLO";
printf("%s",a);
}

Answer: 
Compiler error: Too many initializers


Explanation:
The array a is of size 4 but the string constant requires 6 bytes to get stored.



4)
main()
{
char a[4]="HELL";
printf("%s",a);
}

Answer: 
HELL%@!~@!@???@~~!


Explanation:
The character array has the memory just enough to hold the string “HELL” and doesnt have enough space to store the terminating null character. So it prints the HELL correctly and continues to print garbage values till it accidentally comes across a NULL character.



5)
      main()
     { 
int a=10,*j;
void *k; 
j=k=&a;
   j++;  
k++;
   printf("\n %u %u ",j,k);
      } 

Answer: 
Compiler error: Cannot increment a void pointer


Explanation:
Void pointers are generic pointers and they can be used only when the type is not known and as an intermediate address storage type. No pointer arithmetic can be done on it and you cannot apply indirection operator (*) on void pointers.

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