-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat.c
More file actions
26 lines (20 loc) · 718 Bytes
/
Copy pathfloat.c
File metadata and controls
26 lines (20 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
int main()
{
// variable = A reusable container for value
// behaves as if it were the value it contains
/*
%f is the format specifier for the float data type
%.2f shows only 2 decimal points
\n is the newline character
; all lines should end with the semi colon
We can only store store 6 or seven decimal points with precision in the float datatype. Therefore to use more decimals with precision, we can use the double datatype.
*/
float gpa = 2.5;
float price = 19.99;
float temperature = 40.2;
printf("Your gpa is %f\n", gpa);
printf("The price is $%.2f\n", price);
printf("The temperature is %fF\n", temperature);
return 0;
}