Hay!
In this post we will teach you how to add two numbers in C language. So for this purpose we will need three integer variables or in case you want to add floating point numbers then you will need three floating point variables. We will take input of two numbers and will store it in third variable.
So lets start.
Code:
#include<stdio.h>
#include<conio.h>void main(void)
{
int a,b,c;
printf("Enter 1st number");
scanf("%d",&a);
printf("Enter 2nd number");
scanf("%d",&b);
c=a+b;
printf("Sum is %d",c);
getch();
}
Output:
In Similar way you can subtract, multiply and divide two numbers just by following changes:
c=a-b for subtracting
c=a*b for multiplying
c=a/b for dividing
Don't Forget to share your views with us.
No comments:
Post a Comment