C best language questions and answer

(q) What will be output of the following program ?

 

#include"stdio.h"

void  main(){

char a='\377';

clrscr();

printf(2+"%d%o",a);

getch();

 

}

 

output:177777

Explanation:

‘\377’ is octal character constant.

%o is used to print octal number system.

(q) What will be output of the following program ?

 

#include"stdio.h"

void  main(){

char a='\378';

clrscr();

printf("%o",a);

getch();

 

}

 

output:error ,character constant too much long

Expalnation: Heigest possible character constant is ‘\377’ which is

Equivlalent to decimal 255.

No comments: