Challenge: Profile Card
Completed
Create an int variable age with value 21, a double height with value 1.65 and a char grade with value 'B'. Print them like this:
Age: 21 Height: 1.65 Grade: B
Input
None.
Output
The three lines above.
Example
Output
Age: 21 Height: 1.65 Grade: B
Editor
C
Hints
Use %d for int, %f for double and %c for char.
%.2f prints exactly 2 decimals.
Solution explanation
Each variable has a type that fits its value, and each type has its own placeholder.
Show solution
#include <stdio.h>
int main() {
int age = 21;
double height = 1.65;
char grade = 'B';
printf("Age: %d\n", age);
printf("Height: %.2f\n", height);
printf("Grade: %c\n", grade);
return 0;
} Output
Answer
You can practice without logging in. Log in to save completion.
Save your progress
You're practising as a guest, so your progress won't be saved.
- Track every lab you complete
- Earn verifiable lab certificates
- See your progress in every module