Home | Add to Favorites | Ebooks Directory | News  
C ,C++  Programming
Home
C , C ++  Article
C and C++  Tutorial 
C++  compiler
C++  Books
C and C++ Questions
C ++ Coding
C++ Source Code
C riddles and questions on Printf Function
     
Printf Function  and Questions.
              

int Printf(const char * string ,...);

        The printf function returns the number of characters printed or a negative value if an error occurs

1.printf("%d",printf("exams"));

now the output will be exams5.
 

 

2.char *ptr=(char *)1000;
  printf(ptr);


Here simply  an address value  is passed so, some garbage value in that address will be printed

3.printf("%%%%")

simple question. %% will be printed.

4.int i=1;
 
 printf("%d",++i,i++,++i);

 
 4   will be printed. first all the increment operations will be performed right to left).then the format specifiers and the arguments are matched in order
from left to right. so 4 is the answer.

 i=1;
 
 printf("%d%d",i++,++i,i++);

 now 3,3 will be printed.since we have i++ first.
 
i=1;
printf("%d%d%d",++i,i++,i++);

  4,2,1 will be the answer.


5. printf("exams"+2);

  "ams" will be printed.
 
when we pass  a string to any function only the base address of will be passed. Here the base address plus two gets passed. So the printf function starts printing from the third character
. .int a1[]={4,5};

printf("%d%d",0[a],a[0]);

same value will be printed twice.

7.printf("%C","boring"[4]);

'n' will be printed.

Go To Index