C Program two add two digits.



In this post today we are going to  implement a  simple C program to add two number.For that we need total three variables two variables to initialize the with  numbers and the third to store the result of the sum.In the first program we are going to implement the sum  of two integers numbers and  in the other we are going to add two floating  point numbers.

1.Adding  two integer  numbers.



1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
   int a=5,b=10,sum;
   clrscr();
   sum=a+b;
   printf("The sum of a and b is:%d",sum);
}

2.Adding two float numbers.



1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
   float a=5.1,b=10.3,sum;
   clrscr();
   sum=a+b;
   printf("The sum of a and b is:%f",sum);
}

Comments