C Program to Add Two Float Numbers || Add Two Floating Point Numbers

C Program to Add Two Float Numbers

C Program To Add Two Float Number. If you are looking for the addition of two floating numbers program in C, here is the full tutorial we will help you to learn how to write a c program to add two floating numbers. Three different types of float numbers addition are here.

Float Number in C


Example #1: Add Two Float Numbers

#include<stdio.h>                              //this is an header file

main()                                                // main is the starting of a program

{                                                         //start bracket

 float x,y,z;                                         //include floating data-type 

 x=10.5;                                             //first floating data

 y=20.2;                                             //second floating data

 z=x+y;                                              // store the data in 'z' variable

 printf("Total Number Is %f",z);           //print the result

 getch();                                             //hold the output screen

}                                                        //end bracket




Output of Program:

10.5

20.2

Total Number Is 30.700001



Example #2: C Program to Add Two Floating Numbers


#include<stdio.h>

main()

{

 float x,y,z;

 printf("Enter First Number\n");

 scanf("%f",&x);

 printf("Enter Second Number\n");

 scanf("%f",&y);

 z=x+y;

 printf("Total Number Is %f",z);

 getch();

}



Output of Program:


Add Two Float Number in C





Example #3: Add Two Floating Numbers in C

#include<stdio.h>

main()

{

 float x,y,z;
 printf("Enter Two Number:\n");
 scanf("%f%f",&x,&y);

 z=x+y;

 printf("Total Number Is %f",z);

 getch();

}



Output of Program:


C Program to Add Two Float Numbers





Post a Comment

1 Comments