#include<stdio.h>

main (){


double I;

printf ("Enter the value : ");
scanf ("%lf",&I);

while(I<=0){
printf("**Value must be greater than 0.0\n");
printf("**Try again. : ");
scanf ("%lf", &I);}

WHAT DO I HAVE TO ENTER HERE?

printf(" I is %lf\n", I);

}

Hi! I create a code so that it checks if the value is negative it asks 
the user again till it get a a value that's greater then 0 but after it has done that how do i check if the user has entered a value that ends with a period( 5.. or 5.5. or -5..), how do i return a error msg.

Recommended Answers

All 3 Replies

#include<stdio.h>

main (){


double I;

printf ("Enter the value : ");
scanf ("%lf",&I);

while(I<=0){
printf("**Value must be greater than 0.0\n");
printf("**Try again. : ");
scanf ("%lf", &I);}

WHAT DO I HAVE TO ENTER HERE?

printf(" I is %lf\n", I);

}

Hello sir I'm amit I'm so confused because I can't understand 'C' language please help me

Hi! I create a code so that it checks if the value is negative, it asks
the user again till it get a a value that's greater then 0 but after it has done that how do i check if the user has entered a value that ends with a period( 5.. or 5.5. or -5..), how do i return a error msg.

Hey this is a C question and you have posted it in a C++ forum.

If I am not wrong then you don't want to accept numbers 5 5.5 -5.5 -5 and similar...
So you can do this :

double rem;
rem=fmod(l,5.0);
if(rem > 0) printf("Not an error");
else printf("Error");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.