Not very helpful! In what manner does it "not work"?
The most obvious thing is that x is a float but you told scanf to expect an
int - %d. Why float in any case? Who in the world other than Adrian Mole is
going to enter 13.75 when asked for age?
The compiler options -Wall -Wformat -Werror would have allowed the compiler to
trap this error for you.
Even though SourceForge's implementation is broken, you should apply the new
code mark-up to code when posting.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am new at this and can't figure out why this don't work.... please help me.
include <stdlib.h>
include <stdio.h>
int main()
{
float x;
printf("Please enter your age\n");
scanf("%d", &x);
if( (x>=18) && (x<=55) )
{
printf("Transaction Accepted\n");
}
else {
printf("Transaction Rejected\n");
}
system("PAUSE");
return 0;
}
Not very helpful! In what manner does it "not work"?
The most obvious thing is that x is a float but you told scanf to expect an
int - %d. Why float in any case? Who in the world other than Adrian Mole is
going to enter 13.75 when asked for age?
The compiler options -Wall -Wformat -Werror would have allowed the compiler to
trap this error for you.
Even though SourceForge's implementation is broken, you should apply the new
code mark-up to code when posting.