Monday 2 July 2012

Basic C Programming

Add two numbers

#include <stdio.h>
#include <conio.h>
void main ( )
{
        int a,b,c;
        clrscr ( );
                     
        printf ("\n\n\n\t\t Enter 1st number...:"); scanf ("%d",&a);
        printf ("\n\n\t\t Enter 2nd number...:"); scanf ("%d",&b);
                       
        c = a + b;
                             
        printf ("\n\n\t\t The Sum is....: %d", c);
        getch ( );
}

Click here to contact us

Sum and Average of three numbers

#include <stdio.h>
#include <conio.h>
void main( )
{
       int a,b,c,d=0,e;
       clrscr ( );
         
       printf ("\n Enter 1st number: -"); scanf ("%d",&a);
       printf ("\n Enter 2nd number: -"); scanf ("%d",&b);
       printf ("\n Enter 3rd number: -"); scanf ("%d",&c);
            
       d = a + b + c;
       e = d/3;
                
       printf ("\n The Sum is: - %d", d);
       printf ("\n The Average is: - %d", e);
       getch ( );

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...