Blogger templates

Pages

Wednesday, 18 April 2012

C Program: Addition of Two Numbers With or With Out Using scanf() Function

c program

// ADDITION OF TWO NUMBER: 2 Methods
  1. With the help of scanf() function
  2. without scanf() function
1. Without scanf() Function

#include<stdio.h>
#include<conio.h>
void main()

{
float a,b,c;
clrscr();
a=10.2;
b=5.3;
c=a+b;
printf("Sum of two Numbers=%f" ,c);
getch();
}

Output:

Sum of two Numbers=15.5


2. With the help of scanf() Function:

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf(" Enter the value of a and b:/n");
scanf("%d%d",&a,&b);
c=a+b;
printf("Addition of Two Numbers=%d" , c);
getch();
}

Output:

Enter the value of a and b:
50
40
Addition of Two Numbers=90

  

0 comments:

Post a Comment