- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 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-02-2002 06:11 PM
тАО12-02-2002 06:11 PM
i think i can make a temp variable, but how?
#include
int main(int argc,char*argv[])
{
int ch;
int c;
int iJunk;
c = 0;
ch = ' ';
printf("\nEnter Grade For Quiz 1:\n");
scanf("%d",&c);
ch = getc(stdin);
printf("\nEnter Grade For Quiz 2:\n");
scanf("%d",&c);
ch = getc(stdin);
printf("\nEnter Grade For Quiz 3:\n");
scanf("%d",&c);
ch = getc(stdin);
printf("\nEnter Grade For Test 1:\n");
scanf("%d",&c);
ch = getc(stdin);
printf("\nEnter Grade For Test 2:\n");
scanf("%d",&c);
ch = getc(stdin);
if(c>=90)
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");
ch = getc(stdin);
return 0;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 07:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 08:26 PM
тАО12-02-2002 08:26 PM
Re: C Program, im stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 08:34 PM
тАО12-02-2002 08:34 PM
Re: C Program, im stuck
Use an array for the scores or
declare another int
int tot;
then after each getc(stdin) line do this:
tot += c;
then before the IF tests do this:
c = tot / 5;
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 08:55 PM
тАО12-02-2002 08:55 PM
Re: C Program, im stuck
#include
int main(int argc,char*argv[])
{
int ch;
int c;
int iJunk;
int tot;
c = 0;
ch = ' ';
printf("\nEnter Grade For Quiz 1:\n");
scanf("%d",&c);
ch = getc(stdin);
tot += c;
printf("\nEnter Grade For Quiz 2:\n");
scanf("%d",&c);
ch = getc(stdin);
tot += c;
printf("\nEnter Grade For Quiz 3:\n");
scanf("%d",&c);
ch = getc(stdin);
tot += c;
printf("\nEnter Grade For Test 1:\n");
scanf("%d",&c);
ch = getc(stdin);
tot += c;
printf("\nEnter Grade For Test 2:\n");
scanf("%d",&c);
ch = getc(stdin);
tot += c;
c = tot / 5;
if(c>=90)
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");
ch = getc(stdin);
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 09:10 PM
тАО12-02-2002 09:10 PM
Re: C Program, im stuck
Let me know if you need more help in modifying it.
#include
#include
#define MAX 10
main(argc,argv)
int argc;
char *argv[];
{
int i,j, buff[MAX], k, avr;
k=0;
if(argc != 2){
printf("Usage: %s
exit(1);
}
i = atof(argv[1]);
for(j=0;j printf("Enter the Marks for Quiz %d:", (j+1));
scanf("%d", &buff[j]);
}
for(j=0;j k=k+buff[j];
avr = k/i;
if(avr>80)
printf("You have Got Grade A\n");
if((avr>60) && (avr<80))
printf("You have Got Grade B\n");
if((avr>40) && (avr<60))
printf("You have Got Grade C\n");
if(avr<40)
printf("You Have failed\n");
printf("Average=%d\n", avr);
}
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 10:24 PM
тАО12-02-2002 10:24 PM
Re: C Program, im stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 10:26 PM
тАО12-02-2002 10:26 PM
Re: C Program, im stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 10:31 PM
тАО12-02-2002 10:31 PM
Re: C Program, im stuck
the code posted by Rajeev works fine!
Did you compile the program?
==============================
L1000: home/yogeeraj>cc test2.c
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (test2.o) was detected. The linked output may not run on a PA 1.x system.
L1000: home/deg>a.out
Usage: a.out
L1000: home/yogeeraj>a.out 11
Enter the Marks for Quiz 1:12
Enter the Marks for Quiz 2:12
Enter the Marks for Quiz 3:34
Enter the Marks for Quiz 4:45
Enter the Marks for Quiz 5:67
Enter the Marks for Quiz 6:34
Enter the Marks for Quiz 7:67
Enter the Marks for Quiz 8:34
Enter the Marks for Quiz 9:67
Enter the Marks for Quiz 10:345
Enter the Marks for Quiz 11:345
You have Got Grade A
Average=193
L1000: home/yogeeraj>
==============================
Why don't describe your problem with an example?
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2002 10:37 PM
тАО12-02-2002 10:37 PM
Re: C Program, im stuck
the code posted by Rajeev works fine!
Did you compile the program?
==============================
L1000: home/yogeeraj>cc test2.c
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (test2.o) was detected. The linked output may not run on a PA 1.x system.
L1000: home/deg>a.out
Usage: a.out
L1000: home/yogeeraj>a.out 11
Enter the Marks for Quiz 1:12
Enter the Marks for Quiz 2:12
Enter the Marks for Quiz 3:34
Enter the Marks for Quiz 4:45
Enter the Marks for Quiz 5:67
Enter the Marks for Quiz 6:34
Enter the Marks for Quiz 7:67
Enter the Marks for Quiz 8:34
Enter the Marks for Quiz 9:67
Enter the Marks for Quiz 10:345
Enter the Marks for Quiz 11:345
You have Got Grade A
Average=193
L1000: home/yogeeraj>
==============================
Why don't describe your problem with an example?
regards
Yogeeraj