C Program To Find Sum Of Two Numbers

 

C Program To Find sum of two numbers

In this example, you will learn to calculate Sum Of Two Numbers Using printf() And scanf() Functions.

How Program Works ??

This Program Can Be Run By Two Ways (1) Using printf() Or (2) Using scanf() 

If You Entered a=10 And B=15 Then

It Represent As sum = a + b;

where a = 10 , b = 15 And Answers Which Sum = 25;

Code For  " Find Sum Of Two Numbers ", Using  printf() Function.

/* Author --> HARSH PATEL */

#include<stdio.h>
void main()
{
    int a = 10; //You Can Add Any Number
    int b = 20; //You Can Add Any Number

    int c = a + b; //Now int C Calculate Sum Of Two Numbers Which You Added On a & b

    printf("Sum Of Two Numbers = %d",c);
}
OUTPUT For Sum Of Two Numbers ", Using  printf()  Function.

Sum Of Two Numbers = 30



Now Using 

scanf()

 Function.


Now Code For  " Find Sum Of Two Numbers ", Using  scanf() Function.

/* Author --> HARSH PATEL */

#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("Sum Of Two Numbers = %d",sum);
    return 0;
}
OUTPUT For Sum Of Two Numbers ", Using  scanf() Function.

Enter First Number : 5
Enter Second Number : 5
Sum Of Two Numbers = 10
  • Now Program End Without Any Error.
🖥️ Learn Programming Languages Free In Our Website Coding With Harsh 
👨‍🎓 5000+ Happy Visitor 👩‍🎓
🌐 Free Programing Examples In WebsitCoding With Harsh 

  • If Any Query Regarding Programs, Website Or More Details Email Us On Contact@CodingWithHarsh.gq

Popular posts from this blog

C Program To Print Hello World

Declare And Initialize Two Character Constants And Output It To User

C Program To Calculate Profit Or Loss