Format Strings:
%d - integer
%f - float
%c - character
Then we come to the statement c=a+b. This statement will add the value of a and b and store into variable c. then printf() statement will print the value of c variable on the screen. Here + is an arithmetic operator. More arithmetic operators can be used such as - (subtract), * (Multiply), / (Divide), % (Mod or Remainder). getch() statement is a get character statement. It pause the output until user presses a key from the keyboard.
#include<stdio.h> // standard input output header file
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("enter any number");
scanf("%d",&a); // or cin >> a
printf("enter any number");
scanf("%d",&b);
c=a+b;
printf("%d",c);
getch();
}
Other C & C++ Programs:
C program to generate even numbers
C program to generate odd numbers
C program to generate table of any given number
C program to generate pyramid of stars
C program to generate upside down pyramid of stars
C program to generate beep sound
C program to generate melodious sound
C program to generate concentric circles using graphics
C program to add, multiply, subtract, divide two numbers
No comments:
Post a Comment