Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, March 10, 2015

What is float data type ?

A float is a data type and it also a keyword which is used to declare a variable as a real constant. The float data type occupies four bytes (32 bits) in memory. The range of float data type from -3.4e38 to +3.4e38. Format specifier of float data type is ‘%f’.
Syntax:
            float variable_name;
Ex:
     float average, percentage;

Program: Find the average of 5 real numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
     float a, b, c, d, e;
     float average;
     printf(“Enter Five Real Numbers : “);
     scanf(“%f%f%f%f%f”,&a, &b, &c, &d, &e);
     average = ( a + b + c + d + e ) / 5.0;
     printf(“Average = %f”, average);
     getch();
}
Output:
Enter Five Real Number : 1.203 2.403 12.45 10.46 21.89


Average = 9.681200

No comments:

Post a Comment