- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Part II C program im stuck
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 12:05 PM
тАО12-03-2002 12:05 PM
something like this
=(quizavg * 0.30)+(testsavg * 0.70)
if(c>=90)
then give it a final grade from the weighted grade. anyhelp with this?
printf("You get an A\n");
else if((c>=80)&&(c<89))
printf("You get a B\n");
else if((c>=70)&&(c<79))
printf("You get a C\n");
else if((c>=60)&&(c<69))
printf("You get a D\n");
else
printf("Failed the class\n");
#include
struct student_info{
char fname[26];
char lname[31];
int quiza[4];
int quizb[4];
int quizc[4];
int testa[4];
int testb[4];
};
typedef struct student_info SI;
int main()
{
SI student[5];
int iJunk;
int iCount;
int quiztot;
int quizavg;
int testtot;
int testavg;
for (iCount = 0; iCount < 3; iCount++){
printf("Students First Name:");
scanf("%s", student[iCount].fname );
iJunk = getchar();
printf("Students Last Name:");
scanf("%s", student[iCount].lname );
iJunk = getchar();
printf("Score for Quiz 1:");
scanf("%d", &student[iCount].quiza );
iJunk = getchar();
printf("Score for Quiz 2:");
scanf("%d", &student[iCount].quizb );
iJunk = getchar();
printf("Score For Quiz 3:");
scanf("%d", &student[iCount].quizc );
iJunk = getchar();
printf("Score For Test 1:");
scanf("%d", &student[iCount].testa );
iJunk = getchar();
printf("Score For Test 2:");
scanf("%d", &student[iCount].testb );
iJunk = getchar();
quiztot = SI.quiza + SI.quizb + SI.quizc;
quizavg = quiztot/3;
testtot = SI.testa + SI.testb;
testavg = testtot/2;
}
printf("\n");
printf("Press a key to continue...\n");
iJunk = getchar();
return 0;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 02:47 PM
тАО12-03-2002 02:47 PM
Re: Part II C program im stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 03:49 PM
тАО12-03-2002 03:49 PM
SolutionSeems to me you have defined a datastructure type called SI then made an instance of it called student[].
You then went through a routine which filled student[] with info from keyboard input. I assume this part works OK.
Now you say
"quiztot = SI.quiza + SI.quizb + SI.quizc;
quizavg = quiztot/3; "
But SI is now the type and not the student[] so it is not clear to me what SI.testa refers to. I would think you would need to say:
quiztot = student[iCount].quiza + student[iCount].quizb + student[iCount].quizc
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 03:52 PM
тАО12-03-2002 03:52 PM
Re: Part II C program im stuck
#include
struct data {
char fname[26];
char lname[31];
int quiza, quizb, quizc, testa, testb, grade;
};
main()
{
struct data student[3];
int i, q_total, t_total, q_avg, t_avg;
for (i=0; i<3; i++){
printf("Enter the record No. %d\n", (i+1));
printf("Enter the Students first Name & Second Name: ");
scanf("%s %s", &student[i].fname, &student[i].lname);
printf("Enter the Marks %s %s Got in Quiz A: ", student[i].fname, student[i].lname);
scanf("%d", &student[i].quiza);
printf("Enter the Marks %s %s Got in Quiz B: ", student[i].fname, student[i].lname);
scanf("%d", &student[i].quizb);
printf("Enter the Marks %s %s Got in Quiz C: ", student[i].fname, student[i].lname);
scanf("%d", &student[i].quizc);
printf("Enter the Marks %s %s Got in Test 1: ", student[i].fname, student[i].lname);
scanf("%d", &student[i].testa);
printf("Enter the Marks %s %s Got in Test 2: ", student[i].fname, student[i].lname);
scanf("%d", &student[i].testb);
q_avg = ((student[i].quiza)+(student[i].quizb)+(student[i].quizc))/3;
t_avg = ((student[i].testa)+(student[i].testb))/2;
student[i].grade = (q_avg*0.3)+(t_avg*0.7);
if((student[i].grade)>80)
printf("You have Got Grade A\n");
if((student[i].grade)>60 && (student[i].grade)<80)
printf("You have Got Grade B\n");
if((student[i].grade)>40 && (student[i].grade)<60)
printf("You have Got Grade C\n");
if((student[i].grade)<40)
printf("You Have failed\n");
printf("Average=%d\n", (student[i].grade));
}
puts("");
printf("________________________________________________\n");
for (i=0; i<3; i++)
printf("Entry No: %d, \n\t\t Name: %s %s\n\t\t Grade:%d\n", (i+1), student[i].fname, student[i].lname, student[i].grade);
printf("________________________________________________\n");
}
Let me know if u need more help.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 04:17 PM
тАО12-03-2002 04:17 PM
Re: Part II C program im stuck
also if i wanted to get a average grade of everyone i entered how do i do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 04:24 PM
тАО12-03-2002 04:24 PM
Re: Part II C program im stuck
Just compile and try running it you'll know what is does.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 06:20 PM
тАО12-03-2002 06:20 PM
Re: Part II C program im stuck
%s %s\n\t\t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 06:42 PM
тАО12-03-2002 06:42 PM
Re: Part II C program im stuck
Thats for a "TAB" singe \t is single TAB. This is used to have a formatted output on the screen.
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2002 09:24 PM
тАО12-03-2002 09:24 PM
Re: Part II C program im stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 12:05 AM
тАО12-04-2002 12:05 AM
Re: Part II C program im stuck
The structure element grade has all data for the class so make a loop and add all the elements and divide by number of students which you have defined as 3.
for(i=0;i<3;i++)
sum+=(student[i].grade);
av_class_grade=(sum)/3;
Cheers
Rajeev