Help with program, not sure whats wrong

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

#include <iostream>
using namespace std;

int main ()
{


int a,e,i,j;
double b,d,g;
double f[30];
e=g=0;


  cout << "Input Number:  ";
  cin >> a;

  if (a<0)a = a*-1;


do  {

  b=a; e=e+1; f[e]=d=((b/10)-(a/10))*10; a=a/10; g=g+d;
 
  }  while ( a>=1);

  cout << "In Order: ";
  for(i=e;i>=1;i--) {cout << f[i] << " ";}
  cout << "\n";

  cout << "Reverse Order: " ;
  for(j=1;j<=e;j++) cout << f[j] << " ";
  cout << "\n";

  cout << "Sum of the Digits: " << g;
  cout << "\n";

  return 0;
  system "PAUSE"


I'm getting an error on line 12 and i'm not sure why. It ran without the system "PAUSE" at the end. Not sure if it worked but it did compile. Can someone please tell me what is wrong. Again I am new to this.
You should use "system("Pause");". Also you shouldn't use system function, it's not safe and makes your executables be marked as viruses, and your System function will not be executed, because you put it after "return 0;".
Thank you, that did it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<iostream>

using namespace std;

int main(void)
{
char letter[5]={'F', 'D', 'C', 'B', 'A'};
int grades[5]={0};
int temp, count=0;
do{
cout << "Input Grade: ";
cin >> temp;
if (temp>=0 && temp <=4){
grades[temp]++;
count++;
}

}while (temp!=-1);
cout<< "Total: "<< count<<" grades."<<endl;
for (int i=4;i>=0;i--)
cout << letter[i] <<": " << grades[i]<<endl;

system ("PAUSE");
return 0;
}


I have to create a program that will accept any number of exam scores. after all the scores have been entered i need allow the user to use -1 to exit then output the number of grades in each category. It will let me enter the grades but when i hit the -1 it just takes off. so i'm not sure what i really did and i'm really confused.

Never mind i kept hitting i instead of 1 lmao
Last edited on
Topic archived. No new replies allowed.