Calculations

C program to the sum of two numbers

C program to the sum of two numbers

In this tutorial, we will discuss the C program to the sum of two numbers.

In this topic, we will learn how to find the sum of two integer number in C language

Sum of two integer

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int num_1=56,num_2=34,sum;
//value already assigned
    sum=num_1+num_2;//calculate sum
    printf("\sum of these numbers: %d ",sum);//display sum value
    getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

sum of these numbers: 90

 

Sum of two integer- get user input

Program 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int num_1,num_2,sum;//declared variable
    printf("\Enter two integer value: ");
   scanf("%d %d",&num_1,&num_2);
   //call the scanf() function to store values entered by user
    sum=num_1+num_2;
    //calculate sum of two numbers in stored in variable sum
    printf("%d + %d =%d:",num_1,num_2,sum);//display sum of numbers
    getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Enter two integer value: 45 65
45 + 65 = 110

 

In the above program, the user is entered two integer point value for find sum.

we use the pre-defined function scanf() for getting value from the user. So two integer values entered by the user and it is stored in variables num_1 and num_2

Then, te variables num_1 and num_2 are added using plus(+) operator and then the result displaying on the screen using printf() function

 

Suggested post

C++ program to multiply two numbers using function

Java program to multiply two numbers using method

Python program to multiply two numbers using function

C# program to multiply two numbers using function

PHP program to multiply two numbers using function

 

C program to multiply two numbers 

C++ program to multiply two numbers

Java program to multiply two numbers 

Python program to multiply two numbers 

C# program to multiply two numbers 

PHP program to multiply two numbers 

JavaScript program to multiply two numbers 

 

Calculate the total of array elements in Java

Calculate the total of array elements in C

Calculate the total of array elements in C++

Java program to calculate sum of array elements

C program to calculate sum of array elements

Java Program to calculate average of array

C Program to calculate average of array

Java Program to calculate average of odd and even numbers in an array

Java Program to calculate average of odd and even numbers

C Program to calculate average of odd and even numbers in an array

C Program to calculate average of odd and even numbers

C++ Program to calculate average of odd and even numbers in an array

C++ Program to calculate average of odd and even numbers

 

Operator in Java

Data types and variable in Java

Find product of two numbers using recursion in Java

 

Python program to sum of two numbers
Java program to multiply two numbers
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago