Saturday 15 May 2010

C string interview questions and answers




(1) Without using any semicolon (;) in program write a c program which output is: HELLO WORLD?

Answer:



void main()

{

if(printf("HELLO WORLD"))

{

}

}

(2)What will be output of following code?

void main()

{

char a[5];

a[0]='q';

a[1]='u';

a[2]='e';

clrscr();

printf("%s",a);

getch();

}



Output: garbage

Explanation: %s is used for string but a is not a string it is only array

No comments:

Post a Comment