Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Reading integers using scanf function

Posted By: Amber Hughes     Category: C Programming     Views: 4612

Reading integers using scanf function.

Code for Reading integers using scanf function in C Programming

main()                                                      
   {                                                           
       int a,b,c,x,y,z;                                        
       int p,q,r;                                              
                                                               
       printf("Enter three integer numbers\n");                
       scanf("%d %*d %d",&a,&b,&c);                            
       printf("%d %d %d \n\n",a,b,c);                          
                                                               
       printf("Enter two 4-digit numbers\n");                  
       scanf("%2d %4d",&x,&y);                                 
       printf("%d %d\n\n", x,y);                               
                                                               
       printf("Enter two integers\n");                         
       scanf("%d %d", &a,&x);                                  
       printf("%d %d \n\n",a,x);                               
                                                               
       printf("Enter a nine digit number\n");                  
       scanf("%3d %4d %3d",&p,&q,&r);                          
       printf("%d %d %d \n\n",p,q,r);                          
                                                               
       printf("Enter two three digit numbers\n");              
       scanf("%d %d",&x,&y);                                   
       printf("%d %d",x,y);                                    
   }  
                                                                                                                      
Output                                                      
   Enter three integer numbers                                 
   1 2 3                                                       
   1 3 -3577                                                   
   Enter two 4-digit numbers                                   
   6789  4321                                                  
   67 89                                                       
   Enter two integers                                          
   44  66                                                      
   4321 44                                                     
   Enter a nine-digit number                                   
   123456789                                                   
   66 1234 567                                                 
   Enter two three-digit numbers                               
   123  456                                                    
   89 123         
                                             
  
Share: 


Didn't find what you were looking for? Find more on Reading integers using scanf function Or get search suggestion and latest updates.

Amber Hughes
Amber Hughes author of Reading integers using scanf function is from London, United Kingdom.
 
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!