Can u help me with this?
Here's the problem.
Everytime i input just 1 word...it works fine.
[IMG]http://img148.imageshack.us/img148/2503/26168475.jpg[/IMG]
but when i enter 2 words this will happen...
[IMG]http://img706.imageshack.us/img706/6625/49110093.jpg[/IMG]
#include <stdio.h>
struct Student{
char course[5];
char subject[5];
char name[20];
float units[8];
float grade[8];
float qpi[3];
}Stud[3];
int main()
{
float grade = 0.0;
float unit = 0.0;
float total = 0.0;
int n,i,x,y;
for(i = 0; i < 3; i++)
{
printf("\nStudent [%d]\n",i+1);
printf("Student name: ");
scanf("%s",Stud[i].name);
printf("Course: ");
scanf("%s",&Stud[i].course);
printf("Number of Subjects: ");
scanf("%d",&n);
for(x = 0; x < n; x++)
{
printf("Subject%d: ",x);
scanf("%s",&Stud[x].subject[x]);
printf("Units: ");
scanf("%f",&Stud[x].units[x]);
unit+=Stud[x].units[x];
printf("Grade: ");
scanf("%f",&Stud[x].grade[x]);
grade = Stud[x].units[x] * Stud[x].grade[x];
total += grade;
}
Stud[i].qpi[i] = total / unit;
printf("\t\t%s = (qpi is: %.2f)\n", Stud[i].name, Stud[i].qpi[i]);
}
printf("\n");
for(y = 0; y < 3; y++)
{
printf("\t\t%s = (qpi is: %.2f)\n", Stud[y].name, Stud[y].qpi[y]);
}
getchar();
getchar();
}