Friends,
In previous article C helpline and A simple "c" program, we were discuss about C Structure and a simple program.In this article we will discuss about a program for addition of two numbers.
Write a program to add two Numbers
//Header files
#include"stdio.h"
#include"conio.h"
//Main function,void show no return any value
Void main()
{
//Declaration of variables
int a,b,sum;
printf("Enter two numbers");
//Take input from user
scanf("%d%d",&a,&b);
sum=a+b;
//show output as a sum of two numbers
printf("sum is=%d",sum);
getch();
}
Output:-
Enter two numbers
12
18
sum is=30
Note:-"//" This symbol show comment for only user understanding.It is not counted in a computer program.
Different data types used in a program written as a user input in a given form:-
Data types
- Integer %d
- long Integer %ld
- Float %f
- Long Float %lf
- character %c
- string %s
No comments:
Post a Comment