C program-addition of two numbers
In this tutorial we will learn that how a C program add two or more numbers.C program - using assaiment operator
#include<stdio.h>
#include<conio.h>
void main()
{
int num1;
int num2;
int sum;
clrscr();
num1=25;
num2=65;
sum=num1+num2;
printf("\n The addition of two numbers is=");
printf("%d",sum);
getch();
}
Output:
C program - using scanf function
#include<stdio.h>
#include<conio.h>
void main()
{
int num1;
int num2;
int sum;
clrscr();
printf("\n Enter the value of first number=");
scanf("%d",&num1);
printf("\n Enter the value of second number=");
scanf("%d",&num2);
sum=num1+num2;
printf("\n The addition of two numbers is=");
printf("%d",sum);
getch();
}
Output:
No comments:
Post a Comment