Monday, July 28, 2014

PRINTF MCQs


1. printf(1+”%d”);

     It starts printing the String Skipping the number of Characters specified before ‘+’ sign

2. Backslash Characters in C
  1. \n - Newline [ Moves Cursor Position to Next Line ]
  2. \b - Back Space [ Moves Cursor Position to 1 character Back ]
  3. \r - Linefeed [ Moves Cursor Position to First Position in Same Line ]
     Example:
     1.  #include<stdio.h>  
2.  void main()  
3.  {  
4.  printf("\nDiicket");  
5.  printf("\bter");  
6.  printf("\rCr");  
    }
    Outout  : Cricket  

3. Two Strings in Printf
      Ex : printf("Computer","Programming")
   1.    Only First String Will be Accepted
      2.    If number of Strings are Seperated by "Comma" then it will accept only
           first Stringf      
    
    4. %d format specifier
 printf("%d %d %d",50,050,0x50);Output:50 40 80

why?
  1. Any number preceded with Zero (040,050,030) are considered as Octal Numbers
  2. Any number preceded with [ 0x / 0X ] (0x40,0x50,0x30) are considered as Hexadecimal Numbers
5. Printf inside printf in C
    printf("%d",printf("%d",printf("%d",num)));  
 
 Output: 134241

Printf Returns total number of Digits 




No comments:

Post a Comment