As you see at below I used "-1" as my sentinel value but my program wants the other 6 values i asked for in scanf too. How can i solve this problem? I just want the user to enter -1 and exit my loop. I would greatly appreciate for your help..
Regards..
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#define N 100
#define ISIMUZUN 15
struct student{
char name[ISIMUZUN];
char surname[ISIMUZUN];
int number;
float final;
float midterm;
float hw1;
float hw2;
float grade;
char *letter;
};
int main(int argc, char *argv[])
{
struct student info[N];
int i=0, total=0,total2=0,j=0;
double mean=0, stddvt=0, temp=0;
int studentcounter=0,aacount=0,bacount=0,bbcount=0,cbcount=0,cccount=0,dccount=0,ddcount=0,ffcount=0,vfcount=0;
float midtotal=0,midavr=0,fintotal=0,finavr=0,hw1total=0,hw1avr=0,hw2total=0,hw2avr=0;
do{ printf("Please enter student's information with blanks between them\n");
scanf( "%d %s %s %f %f %f %f", &info[i].number, info[i].name, info[i].surname, &info[i].midterm, &info[i].final, &info[i].hw1, &info[i].hw2 );
info[i].grade = (info[i].final*0.4)+ (info[i].midterm*0.25)+ (info[i].hw1*0.15) + (info[i].hw2*0.20);
if(info[i].number==-1)
break;
studentcounter=studentcounter+1;
i++;
}while (info[i].number!=-1);