221k views
4 votes
How to write (c program) code for 30/4 = 7.5. It should print 7.5, not 7

User AsukaSong
by
8.9k points

1 Answer

4 votes

Answer:

The program to given question for get the output 7.5. We write the code like this

#include <stdio.h>

int main() //define main method

{

float a; //declare a float variable.

a=30.0/4; //a holding the value

printf("the value of a= %f",a); //print the value.

return 0;

}

output:

7.500000

Step-by-step explanation:

In the above program we declare a variable (a). That's datatype is float because float datatype hold the decimal values.Then we assign the value to variable a that is already given in the question. Then we print the value by using printf() function.

So the output of the given question is 7.5.

User Amir Kost
by
7.7k points