223k views
3 votes
Write a program to enter a number and test if it is greater than 45.6.if the number entered is greater than 45.6 the program needs to out the phrase Greater than 45.6

User Rhh
by
7.9k points

1 Answer

3 votes

Answer:

#include<stdio.h> //header file

int main() //main function

{

float num; // variable declaration

printf("Enter a number to test:\\"); // getting variable for test

scanf("%f", &num);

if (num>45.6) //Testing weather greater or smaller

printf("\\ %f is greater than 45.6", num); // Result if greater

else

printf("\\ %f is not greater than 45.6", num); // Result if smaller or equal

return 0;

}

Step-by-step explanation:

  • First of all , a variable will be declared in float (data type ).
  • User will input data in variable.
  • The variable will be compared using logical operator with 45.6
  • If it is greater, A phrase will be passed that number is greater than 45.6
  • Else if the number will not greater the phrase will say that the number is not greater than 45.6

User Mranders
by
8.0k points

No related questions found