Skip to main content

Posts

Showing posts from 2017

C Program to Add of Two Numbers

The following program performs the arithmetic operation of adding two numbers and prints their sum on the screen. In this example, the user must input two numbers. Declare the Variables: The first step in adding two numbers using C programming is to declare the variables that will store the values of the two numbers. In C programming, we can declare variables using the syntax:  data_type variable_name;  For example, to declare two variables that will store the values of the two numbers, we can use the following code: int num1, num2; Get Input from User: After declaring the variables, we need to get the input from the user. To do this, we can use the scanf() function. The scanf() function reads the input from the user and stores it in the variables. Here is the code to get the input from the user: printf("Enter the first number: "); scanf("%d", &num1); printf("Enter the second number: "); scanf("%d", &num2); Add the Numbers:   Now that we