like when i execute the coding given...its ask me to enter number of student..
i enter 3....then it ask me to enter name, then enter result for 3 subject and then enter gpa for the 3 subjects given...the same repeated for 3 student and the result of the gpa is given at the end ..the example is like below..
the coding is
Quote
#include <stdio.h>
#include <string.h>
void input_name(char name[][10], int stud, float mark_cs1[], float mark_cs2[], float mark_cs3[],int ch_cs1[],int ch_cs2[],int ch_cs3[],float gpa[]);
void input_mark(float mark1[], float mark2[], float mark3[], int i);
void calculate_gpa(float mark1[],float mark2[],float mark3[],int i,float gpa[],int ch_cs1[],int ch_cs2[],int ch_cs3[]);
void input_credithr(int ch_cs1[],int ch_cs2[],int ch_cs3[],int i);
void get_gradepoint(float *);
void main(void)
{
char name [10][10];
float mark_cs1[10];
float mark_cs2[10];
float mark_cs3[10];
int ch_cs1[10];
int ch_cs2[10];
int ch_cs3[10];
float gpa[10];
int i,no_stud=0;
printf("Enter number of student \n");
scanf("%d",&no_stud);
input_name(name,no_stud,mark_cs1,mark_cs2,mark_cs3,ch_cs1,ch_cs2,ch_cs3,gpa);
for (i=0; i<no_stud; i++)
printf("You have entered %s whose GPA is %.2f\n",name[i],gpa[i]);
printf("Thank you \n");
}
void input_name(char name[][10], int stud, float mark_cs1[], float mark_cs2[], float mark_cs3[],int ch_cs1[],int ch_cs2[],int ch_cs3[],float gpa[])
{
int i;
for (i=0; i<stud; i++)
{ printf("Enter a name \n");
scanf("%s",name[i]);
input_mark(mark_cs1,mark_cs2,mark_cs3,i);
input_credithr(ch_cs1,ch_cs2,ch_cs3,i);
calculate_gpa(mark_cs1,mark_cs2,mark_cs3,i,gpa,ch_cs1,ch_cs2,ch_cs3);;
}
}
void input_mark(float mark1[], float mark2[], float mark3[], int i)
{
printf("Enter mark for course 1, 2 and 3 \n");
scanf("%f %f %f",&mark1[i], &mark2[i],&mark3[i]);
}
void calculate_gpa(float mark1[],float mark2[],float mark3[],int i,float gpa[],int ch_cs1[],int ch_cs2[],int ch_cs3[])
{
float subgp1,subgp2,subgp3, totalcredit;
totalcredit = ch_cs1[i]+ch_cs2[i]+ch_cs3[i];
get_gradepoint(&mark1[i]);
subgp1 = mark1[i] * (float)ch_cs1[i];
get_gradepoint(&mark2[i]);
subgp2 = mark2[i] * (float)ch_cs2[i];
get_gradepoint(&mark3[i]);
subgp3 = mark3[i] * (float)ch_cs3[i];
gpa[i] = (subgp1+subgp2+subgp3)/totalcredit;
}
void input_credithr(int ch_cs1[],int ch_cs2[],int ch_cs3[],int i)
{
printf("Enter credit hour for course 1, 2 and 3 \n");
scanf("%d %d %d",&ch_cs1[i], &ch_cs2[i],&ch_cs3[i]);
}
void get_gradepoint(float *mark)
{ if (*mark > 80)
*mark = 4.0;
else if (*mark > 70)
*mark = 3.0;
else if (*mark > 60)
*mark = 2.0;
else if (*mark > 50)
*mark = 1.0;
else if (*mark > 0)
*mark = 0;
}
#include <string.h>
void input_name(char name[][10], int stud, float mark_cs1[], float mark_cs2[], float mark_cs3[],int ch_cs1[],int ch_cs2[],int ch_cs3[],float gpa[]);
void input_mark(float mark1[], float mark2[], float mark3[], int i);
void calculate_gpa(float mark1[],float mark2[],float mark3[],int i,float gpa[],int ch_cs1[],int ch_cs2[],int ch_cs3[]);
void input_credithr(int ch_cs1[],int ch_cs2[],int ch_cs3[],int i);
void get_gradepoint(float *);
void main(void)
{
char name [10][10];
float mark_cs1[10];
float mark_cs2[10];
float mark_cs3[10];
int ch_cs1[10];
int ch_cs2[10];
int ch_cs3[10];
float gpa[10];
int i,no_stud=0;
printf("Enter number of student \n");
scanf("%d",&no_stud);
input_name(name,no_stud,mark_cs1,mark_cs2,mark_cs3,ch_cs1,ch_cs2,ch_cs3,gpa);
for (i=0; i<no_stud; i++)
printf("You have entered %s whose GPA is %.2f\n",name[i],gpa[i]);
printf("Thank you \n");
}
void input_name(char name[][10], int stud, float mark_cs1[], float mark_cs2[], float mark_cs3[],int ch_cs1[],int ch_cs2[],int ch_cs3[],float gpa[])
{
int i;
for (i=0; i<stud; i++)
{ printf("Enter a name \n");
scanf("%s",name[i]);
input_mark(mark_cs1,mark_cs2,mark_cs3,i);
input_credithr(ch_cs1,ch_cs2,ch_cs3,i);
calculate_gpa(mark_cs1,mark_cs2,mark_cs3,i,gpa,ch_cs1,ch_cs2,ch_cs3);;
}
}
void input_mark(float mark1[], float mark2[], float mark3[], int i)
{
printf("Enter mark for course 1, 2 and 3 \n");
scanf("%f %f %f",&mark1[i], &mark2[i],&mark3[i]);
}
void calculate_gpa(float mark1[],float mark2[],float mark3[],int i,float gpa[],int ch_cs1[],int ch_cs2[],int ch_cs3[])
{
float subgp1,subgp2,subgp3, totalcredit;
totalcredit = ch_cs1[i]+ch_cs2[i]+ch_cs3[i];
get_gradepoint(&mark1[i]);
subgp1 = mark1[i] * (float)ch_cs1[i];
get_gradepoint(&mark2[i]);
subgp2 = mark2[i] * (float)ch_cs2[i];
get_gradepoint(&mark3[i]);
subgp3 = mark3[i] * (float)ch_cs3[i];
gpa[i] = (subgp1+subgp2+subgp3)/totalcredit;
}
void input_credithr(int ch_cs1[],int ch_cs2[],int ch_cs3[],int i)
{
printf("Enter credit hour for course 1, 2 and 3 \n");
scanf("%d %d %d",&ch_cs1[i], &ch_cs2[i],&ch_cs3[i]);
}
void get_gradepoint(float *mark)
{ if (*mark > 80)
*mark = 4.0;
else if (*mark > 70)
*mark = 3.0;
else if (*mark > 60)
*mark = 2.0;
else if (*mark > 50)
*mark = 1.0;
else if (*mark > 0)
*mark = 0;
}
output is
Quote
Enter number of student
3
Enter a name
james
Enter mark for course 1, 2 and 3
45 56 78
Enter credit hour for dourse 1, 2 and 3
3 3 3
Enter a name
samuel
Enter mark for course 1, 2 and 3
56 87 88
Enter credit hour for course 1, 2 and 3
3 3 3
Enter a name
kevin
Enter mark for course 1, 2 and 3
78 89 90
Enter credit hour for course 1, 2 and 3
3 3 3
You have entered james whose GPA is 1.33
You have entered samuel whose GPA is 3.00
You have entered kevin whose GPA is 3.67
Thank you
Press any key to continue.
3
Enter a name
james
Enter mark for course 1, 2 and 3
45 56 78
Enter credit hour for dourse 1, 2 and 3
3 3 3
Enter a name
samuel
Enter mark for course 1, 2 and 3
56 87 88
Enter credit hour for course 1, 2 and 3
3 3 3
Enter a name
kevin
Enter mark for course 1, 2 and 3
78 89 90
Enter credit hour for course 1, 2 and 3
3 3 3
You have entered james whose GPA is 1.33
You have entered samuel whose GPA is 3.00
You have entered kevin whose GPA is 3.67
Thank you
Press any key to continue.
my task is to to have exactly same output but by using structure statements...
plz help me...i need to submit it in 2 days.....plz plz plz ...


Sign In
Create Account

Back to top









