- A virus
test banner

Post Top Ad

Responsive Ads Here
Share This

write a program to read a series of words from a terminal using scanf function

program:
   main( )                                                     
   {                                                           
       char word1[40], word2[40], word3[40], word4[40];        
       printf("Enter text : \n");                              
       scanf("%s %s", word1, word2);                           
       scanf("%s", word3);                                     
       scanf("%s", word4);                                     
       printf("\n");                                           
       printf("word1 = %s\nword2 = %s\n", word1, word2);       
       printf("word3 = %s\nword4 = %s\n", word3, word4);       
   } 
 
 
Output                                                      
   Enter text :                                                
   Gill Road, Gill Park                                   
   word1 = Gill                                              
   word2 = Road,                                               
   word3 = Gill                                             
   word4 = Park                                               
   Enter text :                                                
   Gill-Road, Gill-Park Ludhiana Punjab                
   word1 = Gill-Road                                      
   word2 = Gill-Park                                    
   word3 = Ludhiana                                           
   word4 = Punjab
 

No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages