C Language - Strings

You Are Here :: Home > C Language > Strings - General Questions

 
25.

main()

{
char *p="GOOD";
char a[ ]="GOOD";
printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p));
printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a));
}

A. sizeof(p) = 2, sizeof(*p) = 1, strlen(p) = 4
sizeof(a) = 5, strlen(a) = 4
B. sizeof(p) = 2, sizeof(*p) = 2, strlen(p) = 4
sizeof(a) = 5, strlen(a) = 4
C. sizeof(p) = 4, sizeof(*p) = 2, strlen(p) = 4
sizeof(a) = 5, strlen(a) = 4
D. sizeof(p) = 2, sizeof(*p) = 4, strlen(p) = 4
sizeof(a) = 5, strlen(a) = 4




26.

What will be output if you will compile and execute the following c code?

#include
int main(){
char *str;
scanf("%[^\n]",str);
printf("%s",str);
return 0;
}

A. It will accept a word as a string from user. B. It will accept a sentence as a string from user.
C. It will accept a paragraph as a string from user. D. Compiler error




« previous

1

2

3

4

5

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on