i put the getch(); thing and included lybaries but i only opens for a little
heres the code:
#include %26lt;stdio.h%26gt;
#include %26lt;conio.h%26gt;
main()
{
int grade1, grade2, grade3, grade4, grade5, grade6, total, average;
printf("enter grade1: "); /* whitch grade to put in */
scanf("%d", %26amp;grade1);
if (grade1 %26gt;= 90)
printf("A\n\n", grade1);
else
if(grade1 %26gt;= 80)
printf("B\n\n");
else
if (grade1 %26gt;=70)
printf("C\n\n");
else
if (grade1 %26gt;=60)
printf("D\n\n");
else
printf("F\n\n");
printf("enter grade2: ");
scanf("%d", %26amp;grade2);
if (grade2 %26gt;= 90)
printf("A\n\n", grade2);
else
if(grade2 %26gt;= 80)
printf("B\n\n");
else
if (grade2 %26gt;=70)
printf("C\n\n");
else
if (grade2 %26gt;=60)
printf("D\n\n");
else
printf("F\n\n");
printf("enter grade3: ");
scanf("%d", %26amp;grade3);
if (grade1 %26gt;= 90)
printf("A\n\n", grade3);
else
if(grade3 %26gt;= 80)
printf("B\n\n");
else
if (grade3 %26gt;=70)
printf("C\n\n");
else
if (grade3 %26gt;=60)
printf("D\n\n");
else
printf("F\n\n");
printf("enter grade4: ");
scanf("%d", %26amp;grade4);
if (grade4 %26gt;= 90)
printf("A\n\n", grade1);
else
if(grade4 %26gt;= 80)
printf("B\n\n");
else
if (grade4 %26gt;=70)
printf("C\n\n");
else
if (grade4 %26gt;=60)
printf("D\n\n");
else
printf("F\n\n");
printf("enter grade5: ");
scanf("%d", %26amp;grade5);
if (grade5 %26gt;= 90)
printf("A\n\n", grade1);
else
if(grade5 %26gt;= 80)
printf("B\n\n");
else
if (grade5 %26gt;=70)
printf("C\n\n");
else
if (grade5 %26gt;=60)
printf("D\n\n");
else
printf("F\n\n");
printf("enter grade6: ");
scanf("%d", %26amp;grade6);
if (grade6 %26gt;= 90)
printf("A\n\n", grade1);
else
if(grade6 %26gt;= 80)
printf("B\n\n");
else
if (grade6 %26gt;=70)
printf("C\n\n");
else
if (grade6 %26gt;=60)
printf("D\n\n");
else
printf("F\n\n");
total = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6);
/* adds up grades^ */
average = total / 6;
printf("Class average is %d\n", average);
getch();
return 0;
}
So i made my C++ code in notepad but it doesnt open for more than.1 seconds?
either run it from the windows command line (start button -%26gt; run -%26gt; type 'cmd' and hit enter -%26gt; navigate to your program)
or at the end of you program make a temporary variable up... force it to get user input into that temp variable.. this is to do nothing more than to put a check before the program exits.. again temp variable does nothing but give the cin statement something to dump a value to..
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment