questions of c coding and answer

(q) What will be output of the following program ?
#include<stdio.h>
void  main(){
char a='\12';
char *str1="cquestion",*str2="bank";
clrscr();
printf("%s%c%s",str1,a,str2);
getch();
}
Output: cquestion
bank
Explanation:
‘\12’ represents octal 12 i.e. decimal 10 which is ASCII code of new line character i.e. sends the cursor to next line
(q) What will be output of the following program?
#include<stdio.h>
void  main(){
char a='\15';
char *str1="cquestion",*str2="bank";
clrscr();
printf("%s%c%s",str1,a,str2);
getch();
}
Output: bankstion
Explanation:
‘\11’ represent octal 11 i.e. decimal 9 which is ASCII code of carriage return (return to first position of that line)

No comments: