Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Wednesday, February 9, 2011

C2 : Find Sum


Back to Home   &  C



A ))) //Decalre 2 variables and assign value to it and find its sum
#include<stdio.h>
#include<conio.h>
void main()
{
           clrscr();
           int a,b,c;
          a=10;
          b=20;
          c=a+b;
          printf("Result of Addition=%d",c);
          getch();
}
----------------------------------------------
Output :
Result of Addition=30
===============================================

B ))) //Read 2 numbers from keyboard and print its sum
#include<stdio.h>
#include<conio.h>
void main()
{
           clrscr();
           int num1,num2,sum;
           printf("Enter 2 numbers\n");
           scanf("%d%d",&num1,&num2);
           sum=num1+num2;
           printf("Sum=%d",sum);
           getch();
}
----------------------------------------------
Output :
Enter 2 numbers (Enter 2 numbers as per your choice).
12
12
Sum=24
===============================================
// Find sum of 2 numbers

#include<stdio.h>
#include<conio.h>
void main()
{
     clrscr;
          int a,b,c;
          printf("Enter 2 Numbers\n");
          scanf("%d%d",&a,&b);
          c=a+b;
          printf("Sum=%d",c);
   getch();
}


(D) Output :
 Enter 2 Numbers
 3
 4
Sum=7
===============================================
Back to Home   &  C

No comments: