Teacher Grades Program Debug

I need some help with a program Im designing

Page 1 of 1

4 Replies - 1311 Views - Last Post: 05 April 2009 - 06:32 AM Rate Topic: -----

#1 kewlkreator  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 38
  • View blog
  • Posts: 1,065
  • Joined: 25-March 09

Teacher Grades Program Debug

Post icon  Posted 04 April 2009 - 05:52 AM

Hello,
I need some help with my C++ code.
When I try to compile, I get this error message:
C:\Program Files\Microsoft Visual Studio 9.0\VC>cl c\c++\teacher.cpp
Microsoft ® 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright © Microsoft Corporation. All rights reserved.
teacher.cpp
c1xx : fatal error C1083: Cannot open source file: 'c\c++\teacher.cpp': No such
file or directory

C:\Program Files\Microsoft Visual Studio 9.0\VC>cl c:\c++\teacher.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

teacher.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
c:\c++\teacher.cpp(2) : error C2146: syntax error : missing ';' before identifie
r 'std'
c:\c++\teacher.cpp(2) : error C2873: 'namepace' : symbol cannot be used in a usi
ng-declaration
c:\c++\teacher.cpp(2) : error C4430: missing type specifier - int assumed. Note:
 C++ does not support default-int
c:\c++\teacher.cpp(2) : error C2365: 'std' : redefinition; previous definition w
as 'namespace'
c:\c++\teacher.cpp(11) : error C2065: 'cout' : undeclared identifier
c:\c++\teacher.cpp(13) : error C2065: 'cin' : undeclared identifier
c:\c++\teacher.cpp(15) : error C2065: 'cout' : undeclared identifier
c:\c++\teacher.cpp(17) : error C2065: 'cin' : undeclared identifier
c:\c++\teacher.cpp(21) : error C2065: 'cout' : undeclared identifier
c:\c++\teacher.cpp(22) : error C2065: 'cout' : undeclared identifier
c:\c++\teacher.cpp(24) : error C2065: 'cout' : undeclared identifier

C:\Program Files\Microsoft Visual Studio 9.0\VC>


Here is my code, it's a program that is designed to find grade percentages:
#include <iostream>
using namepace std;

//This is a program that teachers can use to calculate grade percentages
//Formula (totalpoints - numbermissed) / totalpoints = grade

int main()
{
int tp,nm,fst,pc; //initializes variables
//--Start code--
cout << "Enter total points possible:/n";
system("pause");
cin >> tp;
system("pause");
cout << "Enter points missed:/n";
system("pause");
cin >> nm;
fst = tp - nm;
pc = fst / tp;
system("pause");
cout << "Grade percentage:/n";
cout << pc;
system("pause");
cout << "Press enter to close.";
return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Teacher Grades Program Debug

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6108
  • View blog
  • Posts: 23,666
  • Joined: 23-August 08

Re: Teacher Grades Program Debug

Posted 04 April 2009 - 07:46 AM

Why are you compiling from the command line???
Was This Post Helpful? 0
  • +
  • -

#3 shteou  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 2
  • Joined: 05-April 09

Re: Teacher Grades Program Debug

Posted 05 April 2009 - 05:48 AM

View PostJackOfAllTrades, on 4 Apr, 2009 - 06:46 AM, said:

Why are you compiling from the command line???


Hi kewlkreator.
I saw this thread posted in a channel I frequent with these exact comments, but I could help reiterating them in lieu of their action.

1) Ignore the above post.
I'm not sure whether he is inept or simply believes this constitutes 'doing someone's homework' and decided it warranted a useless post to bolster his probably tat-driven post-count.
2) You simply misspelt 'namespace'.
The second error mentions this fairly opaquely.

c:\c++\teacher.cpp(2) : error C2146: syntax error : missing ';' before identifier 'std'
c:\c++\teacher.cpp(2) : error C2873: 'namepace' : symbol cannot be used in a using-declaration

You'll get a feel for the C++ errors as you continue.

Additionally, the backslash '\' is used for escaping... so you need \n rather than /n. Though I am sure you would work this out pretty quickly when it was painted ver batim on the canvas.

Cheers,
Stew.
Was This Post Helpful? 1
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6108
  • View blog
  • Posts: 23,666
  • Joined: 23-August 08

Re: Teacher Grades Program Debug

Posted 05 April 2009 - 06:04 AM

Hey Stew, it was an honest question and didn't warrant an ad hominem response from you.

Compiling from the command line in VS is unusual, and fraught with peril for a new user. Garnering the reason for the apparent use of a non-standard means of building a solution in a given tool seems perfectly valid to me. However, I could also make the argument that learning to compile without the use of a GUI is a great way to learn some of the ins and outs of the compilation and linking process, in which case the OP is to be commended.

Irrespective of that, however, nice eye on the misspelling!
Was This Post Helpful? 0
  • +
  • -

#5 shteou  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 2
  • Joined: 05-April 09

Re: Teacher Grades Program Debug

Posted 05 April 2009 - 06:32 AM

View PostJackOfAllTrades, on 5 Apr, 2009 - 05:04 AM, said:

Hey Stew, it was an honest question and didn't warrant an ad hominem response from you.

Compiling from the command line in VS is unusual, and fraught with peril for a new user. Garnering the reason for the apparent use of a non-standard means of building a solution in a given tool seems perfectly valid to me. However, I could also make the argument that learning to compile without the use of a GUI is a great way to learn some of the ins and outs of the compilation and linking process, in which case the OP is to be commended.

Irrespective of that, however, nice eye on the misspelling!


Regardless of the argument for and against compiling from the command-line, it really has nothing to do with the errors in question (except the caveat below). Perhaps the only real item of help you'd get from a GUI in this instance would be to stick those errors in a list box.

Caveat: (For kewlkreator) You may also want to enable /EHsc on the command-line as mentioned in the first line of the output (enable Exception Handling).

Regards,
Stew.

This post has been edited by shteou: 05 April 2009 - 06:33 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1