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
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
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
Data types and variable in Java
Find product of two numbers using recursion in Java
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…