Home » Programming » C » Addition of two number program in C

Addition of two number program in C

This article shows that Addition of two number program in C.

Let’s see Example for Addition of two integers:

#include<stdio.h>
int main() {
  
  int a,b,sum;
  
  printf("Enter First Number: ");
  scanf("%d",&a);
  
  printf("Enter Second Number: ");
  scanf("%d",&b);
  
  sum = a + b;
  
  printf("\n %d + %d = %d",a,b,sum);
  
  return 0;
  
  }

Output:

Enter First Number: 10
Enter Second Number: 5

10 + 5 = 15

Quadratic equation program in C.

Let’s see a example for Addition of two Real Numbers:

#include<stdio.h>
int main() {
  
  float a,b,sum;
  
  printf("Enter First Number: ");
  scanf("%f",&a);
  
  printf("Enter Second Number: ");
  scanf("%f",&b);
  
  sum = a + b;
  
  printf("\n %0.2f + %0.2f = %0.2f",a,b,sum);
  
  return 0;
  
  }

Output:

Enter First Number: 10.2
Enter Second Number: 5

10.20 + 5.00 = 15.20
Note: If you interested lo learn C through web, You can click here

Conclusion:

Hi guys, I can hope that you can know that how to write a Addition of two number program in C. If you like this post as well as know something new so share this article in your social media accounts. If you have any doubt related to this post then you ask in comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *