Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Printing of characters and strings

Posted By: Owen Bouchard     Category: C Programming     Views: 2502

Printing of characters and strings.

Code for Printing of characters and strings in C Programming

main()                                                      
   {                                                           
       char x = 'A';                                           
       staticchar  name[20] = "ANIL KUMAR GUPTA";             
                                                               
       printf("OUTPUT OF CHARACTERS\n\n");                     
       printf("%c\n%3c\n%5c\n", x,x,x);                        
       printf("%3c\n%c\n", x,x);                               
       printf("\n");                                           
                                                               
       printf("OUTPUT OF STRINGS\n\n");                        
       printf("%s\n", name);                                   
       printf("%20s\n", name);                                 
       printf("%20.10s\n", name);                              
       printf("%.5s\n", name);                                 
       printf("%-20.10s\n", name);                             
       printf("%5s\n", name);                                  
   }                                                           
                                                               
Output                                                      
                                                               
   OUTPUT OF CHARACTERS                                        
                                                               
    A                                                           
      A                                                         
        A                                                       
      A                                                         
    A                                                           
                                                               
   OUTPUT OF STRINGS                                           
                                                               
   ANIL KUMAR GUPTA                                            
       ANIL KUMAR GUPTA                                        
             ANIL KUMAR                                        
   ANIL                                                        
   ANIL KUMAR                                                  
   ANIL KUMAR GUPTA                                            
  
Share: 


Didn't find what you were looking for? Find more on Printing of characters and strings Or get search suggestion and latest updates.

Owen Bouchard
Owen Bouchard author of Printing of characters and strings is from Montreal, Canada.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!