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 :
3
4
Sum=7
===============================================
No comments:
Post a Comment