Program to accept and assign values of two numbers and print their addition.| Using C language| very Basic| C Program series 02|
👨💻Program to accept values of two numbers and print their addition.
Code:
//Program to accept values of two numbers and print their addition.
#include<stdio.h>
main()
{
int a,b,c;//Here, we declaring three integer variables.
//below will accept the value of variables a and b at compile time.
printf("Program to find addition of two integer number\n");
//Using printf function to display given line.
//here we used \n to go to the new line.
printf("Enter the value of a:");
scanf("%d",&a);
//scanf function is used to take value from the user.
//%d is used for the integer value.
//&a is used to set the location where the value of a will be stored in memory.
printf("Enter the value of b:");
scanf("%d",&b);
c=a+b;//to perform operation.
printf("Addition of a=%d and b=%d is %d",a,b,c);
//Using printf function to display given line.
//%d displays the values of variables respectively.
}
Output:
👨💻Program to assign values of two numbers and print their addition.
Code:
//Program to assign values for two numbers and print their addition
#include<stdio.h>
main()
{
int a=10,b=20,c;//Here, we declaring three integer variables.
//above we also assign values of variables a and b at compile time.
printf("Program to fithe nd addition of tintegersger number\n");
//Using printf function to display given line.
//here we used \n to go to the new line.
c=a+b;//to perform operation.
printf("Addition of a=%d and b=%d is %d",a,b,c);
//Using printf function to display given line.
//%d displays the values of variables respectively.
}
Output:
Comments
Post a Comment