Types and operators
Basic types, sizeof, integer division and input with scanf.
C
#include <stdio.h>
int main(void) {
int a = 7, b = 2;
double cgpa = 8.45;
char grade = 'A';
printf("%d %d\n", a / b, a % b);
printf("%.1f\n", (double) a / b);
printf("%.2f %c\n", cgpa, grade);
printf("%zu\n", sizeof(char));
return 0;
}Output
3 1 3.5 8.45 A 1
Dividing two ints throws away the decimals. Cast one side to double to keep them.
Reading input
C
int age;
scanf("%d", &age);The & passes the address of age, so scanf can store a value there. Forgetting it is a classic beginner crash.