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

Engg.... | 02:16 | | Best Blogger Tips
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

  
Please Share it! :)
Do you like this Story?

Get Free Email Updates Daily!

Follow us!

0 comments:

Post a Comment