227k views
4 votes
Write the code to declare a variable to hold the value of the grade you hope to get in this class. What stdio.h input function would be used to get input from the user by the keyboard? Write the code to obtain die volt

1 Answer

6 votes

Answer:

// code to read grade

#include <stdio.h>

// main function

int main(void) {

// if grade is character

char grade;

// if grade is numeric then we can use int or double

// int grade;

// double 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:

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:A

your grade is:A

// code to read die volt

#include <stdio.h>

// main function

int main(void) {

// variable

double die_volt;

printf("Enter die volt:");

// read die volt from user

scanf("%lf",&die_volt);

// print die volt

printf("Entered die volt is:%0.2lf",die_volt);

return 0;

}

Step-by-step explanation:

Read the die volt from user and assign it to variable "die_volt" with the help

of scanf() function.

Output:

Enter die volt:220

Entered die volt is:220.00

User Jakub Synowiec
by
5.9k points