Your Only Destination To Empower Your Computer Programing Knowledge. Sky is not so high, You can Touch it if You Try

A "C" program for addition

This article is about a program for addition of two numbers.
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
  1. Integer
  2. %d
  3. long Integer
  4. %ld
  5. Float
  6. %f
  7. Long Float
  8. %lf
  9. character
  10. %c
  11. string
  12. %s

No comments:

Post a Comment