Challenge: Profile Card

Lab C Beginner 10 points

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
Sample output available
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
HOME LABS COMMUNITY DASHBOARD