Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Update class-03.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Slimer210 committed Feb 9, 2023
1 parent ee4ceb0 commit 24d9c1c
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion school-c-class/class-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ int main() {
char c = 'I';

printf("%d\n", a);
printf("%.2f\n", b);
printf("%.2f\n", b); //%.2 sets the floating point precision to 2
printf("%c\n", c);

printf("%d %.2f %c \n", a, b, c); // You can try out printing all variables value in a line :)
return 0;
}
/*
Expand All @@ -52,5 +54,28 @@ Results:
15
10.02
I
15 10.02 I
*/
```
## Constant Variables
```cpp
const int pressure_pa = 101325;
// const will assign variable that have fixed value
// it cannot be modified until this variable is redeclared
pressure_pa = 99999; // returns error
printf("%i", pressure_pa); // "101325"
```
## Scanf - user input
### Ex9
```cpp
#include <stdio.h>
int main() {
int input = 10;
printf("Please input a number: ");
scanf("%d", &input); // retrieves input from user
printf("The number is %d\n", input);
return 0;
}
```

0 comments on commit 24d9c1c

Please sign in to comment.