- 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-04-2002 06:19 AM
тАО12-04-2002 06:19 AM
Re: Part II C program im stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 05:16 PM
тАО12-04-2002 05:16 PM
Re: Part II C program im stuck
for(iCount=0;iCount<3;iCount++)
sum+=(student[iCount].grade);
av_class_grade=(sum)/3;
if((av_class_grade)>90)//Gives letter grade
printf("They have a A\n", student[iCount].fname, student[iCount].lname);
else if((av_class_grade=(sum))>80 && (av_class_grade=(sum))<= 90)
printf("They have a B\n");
else if((av_class_grade=(sum))>70 && (av_class_grade=(sum))<= 80)
printf("They have a C\n");
else if((av_class_grade=(sum))>60 && (av_class_grade=(sum))<= 70)
printf("They have a D\n");
else if((av_class_grade=(sum))<60)
printf("They failed the class\n");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 05:17 PM
тАО12-04-2002 05:17 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 05:49 PM
тАО12-04-2002 05:49 PM
Re: Part II C program im stuck
int sum, av_class_grade;
after #include
and then just at the end add the following code
sum=0;
for(i=0;i<3;i++)
sum+=(student[i].grade);
av_class_grade=(sum)/3;
printf("%d %d\n", av_class_grade, sum);
if(av_class_grade>80)
printf("The Class has Got Grade A\n");
if(av_class_grade>60 && av_class_grade<80)
printf("The Class has Got Grade B\n");
if(av_class_grade>40 && av_class_grade<60)
printf("The Class has Got Grade C\n");
if(av_class_grade<40)
printf("The Class has failed\n");
it should work.
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 06:28 PM
тАО12-04-2002 06:28 PM
Re: Part II C program im stuck
could i just make a variable for the students so ican add more than 3?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 06:40 PM
тАО12-04-2002 06:40 PM
Re: Part II C program im stuck
main(argc, argv)
int argc;
char *argv[];
{
if (argc != 2){
printf("Usage: %s
exit(1);
}
Then continue with the normal codes...
cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 06:48 PM
тАО12-04-2002 06:48 PM
Re: Part II C program im stuck
im having problems with it printing to the final output. it gives some funky numbers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 06:59 PM
тАО12-04-2002 06:59 PM
Re: Part II C program im stuck
no of student say x=atoi(argv[1]);
and then u'll have to change the student count from 3 to the x variable where ever you are doing for(i=0;i<3...make x
The program should be fine after that.
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2002 08:15 PM
тАО12-04-2002 08:15 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 08:45 PM
тАО12-04-2002 08:45 PM
Re: Part II C program im stuck
#include
int sum, av_class_grade;
struct data {
char fname[26];
char lname[31];
int quiza, quizb, quizc, testa, testb, grade;
};
main(argc, argv)
int argc;
char *argv[];
{
struct data student[3];
int i, q_total, t_total, q_avg, t_avg;
int x;
if(argc != 2){
printf("Usage: %s
exit(1);
}
x=atoi(argv[1]);
for (i=0; i
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
printf("________________________________________________\n");
sum=0;
for(i=0;i
av_class_grade=(sum)/3;
if(av_class_grade>80)
printf("The Class has Got Grade A\n");
if(av_class_grade>60 && av_class_grade<80)
printf("The Class has Got Grade B\n");
if(av_class_grade>40 && av_class_grade<60)
printf("The Class has Got Grade C\n");
if(av_class_grade<40)
printf("The Class has failed\n");
}
Just copy and run this with number of students as argument.
Cheers
Rajeev