Table of Contents
How to print sum of two numbers in c?
Program : C Program to find sum of two numbers
- #include
- int main() {
- int a, b, sum;
- printf(“\nEnter two no: “);
- scanf(“\%d \%d”, &a, &b);
- sum = a + b;
- printf(“Sum : \%d”, sum);
- return(0);
How to input 2 values in c?
printf(“Enter two integers: “); scanf(“\%d \%d”, &number1, &number2); Then, these two numbers are added using the + operator, and the result is stored in the sum variable. Finally, the printf() function is used to display the sum of numbers. printf(“\%d + \%d = \%d”, number1, number2, sum);
How do you add two numbers in C++?
sum = num1 + num2; After that it is displayed on screen using the cout object.
How to sum two numbers in C programming?
To understand this example, you should have the knowledge of the following C programming topics: In this program, the user is asked to enter two integers. These two integers are stored in variables number1 and number2 respectively. Then, these two numbers are added using the + operator, and the result is stored in the sum variable.
How do you add two integers in C program?
C Program to Add Two Integers. In this example, the user is asked to enter two integers. Then, the sum of these two integers is calculated and displayed on the screen. Then, these two numbers are added using the + operator, and the result is stored in the sum variable. sum = number1 + number2;
What is the LCM of two integers n1 and N2?
The LCM of two integers n1 and n2 is the smallest positive integer that is perfectly divisible by both n1 and n2 (without a remainder). For example: the LCM of 72 and 120 is 360.
How to find the GCD of two numbers in C programming?
If this test condition is not true, minMultiple is incremented by 1 and the iteration continues until the test expression of if statement is true. The LCM of two numbers can also be found using the formula: LCM = (num1*num2)/GCD. Learn more on, how to find the GCD of two numbers in C programming.