PROGRAM TO ADD TWO NUMBERS
#include<stdio.h> *header file
#include<conio.h> *header file
void main ( ) *main function
{
int a,b,c; *declaration of variables
clrscr ( );
printf( " please enter two numbers " );
scanf( "%d%d",a,b); * taking input from user
c = a + b; * formula used
printf ( "%d",c); * command to get output
getch ( );
}
NOTE - EXPLANATION IS GIVEN IN RED.
- SEE HOW printf AND scanf statements are written ( SYNTAX ) .
- NOTICE HOW %d IS USED TWICE SINCE WE ARE TAKING INPUT OF TWO INTEGER NUMBERS.
- NOTICE HOW %d IS USED TWICE SINCE WE ARE TAKING INPUT OF TWO INTEGER NUMBERS.
No comments:
Post a Comment