179k views
0 votes
Write the code to declare a variable to hold the value of the grade you hope to get in this class.

User Medowlock
by
4.9k points

1 Answer

4 votes

Answer:

// code to declare and read grade

#include <stdio.h>

// main function

int main(void) {

// if grade is character

char grade;

printf("Enter your grade:");

// read grade from user

scanf("%c",&grade);

// print grade

printf("your grade is:%c",grade);

return 0;

}

Step-by-step explanation:

Declare a char variable "grade" to store your grade in the class.If the grade is numeric then we can Declare it as either "double grade;" or "int grade;". To read a value, scanf() function is used from stdio.h.Read a grade from user and assign it to variable "grade".

Output:

Enter your grade:B

your grade is:B

User AlanKley
by
4.9k points