The problem you are having is because of scanf() (This can happen with repeated calls to scanf) There is a non-standard call which helps in some cases. You can put a call to "_flushall()" without the quotes before the troublesome scanf() (obviously it's better to have a strictly correct way of doing it but I haven't gotten one working yet)
When I tried it with _flushall(), it still did not finish reading in a float until I pressed the period key for a decimal, and it would not let me enter any subsequent part of the number, either, despite being a float.
Many programmers recommend using variations of gets and getc but I would not be sure to how to use them to get floats.
I think you can safely read each number into a string (with either scanf() or gets()) and then use atof() to convert the string to a number -- there is no function to convert to float, so pass the string you have read in (instead of a float) to atof() and cast the double it returns to a float So if you read in a string called s, your float would be (float) atof(s). You might get some warnings about potential loss of precision.
The commenter is correct who said you forgot to put in the %f for the raise amount in printf("the raise amount is", &e.ra); and it should be printf("the raise amount is %d", &e.ra);
The other commenter missed the sentence indicating that, when working, this will be run on four faculty members (Once you get it working, you could make an array of four structures, if you chose)
### EDIT ###: This isn't pretty but it works.
void main ()
{
struct Employee e;
int i = 0;
const int NUM_FACULTY = 4;
const int MAX = 81;
char a[MAX];
for(i=0; i < NUM_FACULTY; i++ )
{
printf("Enter employee name: ");
gets(e.name);
printf("Enter current yearly income: ");
gets( a );
e.cye = (float) atof( a );
printf("Enter raise percentage: ");
gets( a );
e.rp = (float) atof( a );
e.ra=(e.cye * e.rp)/100.0;
printf("the raise amount is %f\n", e.ra);
}
system ( "pause" );
}
Explanation:
It avoids the issues with scanf (by reading each float into a string, calling atof() to convert the string to double, and cast the double down to a float -- often floating point variables in programs are made doubles, since the Math functions use doubles and it's the highest precision) and runs four times and gets proper results.
I added a few variables, an array to read the input as a string which will then be converted to float, and a couple of constants to modularize the size of the array and the number of faculty (they are easier to update or isolate problems if declared this way instead of using bald numbers). As noted, the final printf should use e.ra rather than &e.ra.