-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.c
More file actions
31 lines (25 loc) · 949 Bytes
/
Copy pathvariable.c
File metadata and controls
31 lines (25 loc) · 949 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
27
28
29
30
31
#include <stdio.h>
int main()
{
// variable = A reusable container for value
// behaves as if it were the value it contains
// Different types of Variables in C:
// int= whole numbers (4 bytes in modern systems)
// float = single precision decimal number(4 bytes)
// double = double precision decimal number(8 bytes)
// char= single character(1 byte)
// char[]= array of characters(size varies)
// bool= true or false(1 byte, requires <stdbool.h>)
// eg of int: int studentNumber= 23848254;
// float: float time = 9.30;
// double: double
// char: char grade = "A"
// char[]: char studentName[] = "Chris Jose"
// bool: bool isWon = "true";
int age = 25;
int year = 2025;
int quantity = 1;
printf("You are %d years old\n", age); //%d is the format specifier for the integer.
printf("The year is %d\n", year);
printf("You have ordered %d x items\n", quantity);
}