How can I write code in C for the following problem If range

How can I write code in C for the following problem?

If range = 0.1, 0.2, 0.3 .... 0.9 ;
do smth;

If range = 0.01, 0.02, 0.03 .... 0.99;
do smth;

If range = 0.001, 0.002, 0.003 .... 0.999;
do smth;

But output of the program must be just

What is the range?

Solution

Hi, Please let me know in case of any issue.

#include <stdio.h>

int main(){

   // declaration of range variable
   double range = 0.05;

   //1
   if(range >= 0.1 && range <= 0.9){

       //do smth;
   }

   //2
   if(range >= 0.01 && range <= 0.99){

       //do smth;
   }


   //3
   if(range >= 0.001 && range <= 0.999){

       //do smth;
   }

   return 0;
}

/*
What is the range?

   \'range\' is a variable of type double;

*/

How can I write code in C for the following problem? If range = 0.1, 0.2, 0.3 .... 0.9 ; do smth; If range = 0.01, 0.02, 0.03 .... 0.99; do smth; If range = 0.0

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site