Previous Post: Next Post: C #1-A way to start with C Programming C #3-Palindrome or not using C Programming
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a = 10, b = 10;
int c;
clrscr();
c = a+b;
print ("Addition of two numbers a and b is : %d", c);
getch();
}
Output:
Addition of two numbers a and b is : 20
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
clrscr();
printf("Enter the value of a:");
scanf("%d", &a);
printf("Enter the value of b:");
scanf("%d", &b);
c = a+b;
print ("Addition of two numbers a and b is : %d", c);
getch();
}
Output:
Enter the value of a: 10
Enter the value of b: 10
Addition of two numbers a and b is : 20
Explanation:
Addition two numbers using C Programming..
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a = 10, b = 10;
int c;
clrscr();
c = a+b;
print ("Addition of two numbers a and b is : %d", c);
getch();
}
Output:
Addition of two numbers a and b is : 20
Addition of two numbers using C programming getting input from the User Keyboard
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
clrscr();
printf("Enter the value of a:");
scanf("%d", &a);
printf("Enter the value of b:");
scanf("%d", &b);
c = a+b;
print ("Addition of two numbers a and b is : %d", c);
getch();
}
Output:
Enter the value of a: 10
Enter the value of b: 10
Addition of two numbers a and b is : 20
Explanation:
int a, b, c; ------>This line is used to declare the variable, here i have declared variables a and b for inputs and ca for output.
scanf("%d", &a); ------> This line is used to get the input from the user keyboard.
Syntax of scanf():
scanf("access specifier variable type ", address of symbol with variable name);
Like wise b value also will be get from the user by using the scanf() function.
C = a+b; --------> This is the line which add the two number and store it in the C variable.
At-last, Print the value of the C using print statement.
Comments