Hi,
I've finished writing a code to display the integral and fractional part of a number. It's all working fine, however, when asked to enter a number, the program continues to go down to the next line until a letter is entered. Here is the code:
Here is a screenshot of the problem i'm having:Code:/* Intgral and Fraction */ /* By Luke Sowersby */ #include <stdio.h> #include <conio.h> #include <string.h> float fraction, number; char decision; int Round(float number) { return (int)(number); } float fraction2(float fraction) { fraction=(number-Round(number)); return fraction; } void main(void) { Start: printf("Please enter your number, including decimals:\n"); getchar(); scanf("%f%",&number); printf("The integral part of this fraction is: %d",Round(number)); printf("\nThe fractional part of this fraction is: %f",fraction2(fraction)); printf("\nWould you like to re-run the program? (Y or N)\n"); Ask: decision=getch(); if(decision!='Y' && decision!='N') goto Ask; if(decision=='Y') goto Start; }
http://img301.imageshack.us/my.php?i...antedlines.jpg
Thanks, Luke.