| | |
C++ Program have one error :)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 5
Reputation:
Solved Threads: 0
#include <iostream> ;
#include <fstream>;
#include <string> ;
#include <iomanip> ;
using namespace std ;
int main ( )
{
string name;
int m1 ,m2, m3;
float avg;
ofstream outfile("mark.txt") ;
cout<<"Write your name :";
cin>>name;
cout<<"input 3 marks:";
cin>>m1>>m2>m3;
avg=m1+m2+m3/3.0;
cout <<showpoint << fixed << setprecision (2);
cout<<"ur average is :"<<avg<<endl;
outfile<<name<<m1<<""<<m2<<""<<m3;
outfile.close( );
return 0 ;
}
i need to find out whats the error
#include <fstream>;
#include <string> ;
#include <iomanip> ;
using namespace std ;
int main ( )
{
string name;
int m1 ,m2, m3;
float avg;
ofstream outfile("mark.txt") ;
cout<<"Write your name :";
cin>>name;
cout<<"input 3 marks:";
cin>>m1>>m2>m3;
avg=m1+m2+m3/3.0;
cout <<showpoint << fixed << setprecision (2);
cout<<"ur average is :"<<avg<<endl;
outfile<<name<<m1<<""<<m2<<""<<m3;
outfile.close( );
return 0 ;
}
i need to find out whats the error
•
•
Join Date: Jan 2008
Posts: 3,832
Reputation:
Solved Threads: 501
•
•
•
•
#include <iostream> ;
#include <fstream>;
#include <string> ;
#include <iomanip> ;
using namespace std ;
int main ( )
{
string name;
int m1 ,m2, m3;
float avg;
ofstream outfile("mark.txt") ;
cout<<"Write your name :";
cin>>name;
cout<<"input 3 marks:";
cin>>m1>>m2>m3;
avg=m1+m2+m3/3.0;
cout <<showpoint << fixed << setprecision (2);
cout<<"ur average is :"<<avg<<endl;
outfile<<name<<m1<<""<<m2<<""<<m3;
outfile.close( );
return 0 ;
}
i need to find out whats the error
[code]
// paste code here
[/code]
The compiler will tell you exactly what the error is and where. Read the compiler messages closely. You'll get some warnings and an error. Read them carefully. Look at this line, particularly the red, and see if you can find it:
cin>>m1>>m2>m3;
The warnings deal with the fact that you don't need semicolons at the end of the #include statements.
Last edited by VernonDozier; Nov 7th, 2008 at 1:01 pm.
•
•
Join Date: Jun 2008
Posts: 182
Reputation:
Solved Threads: 18
cin>>m2>>m2>m3 missing one '>' before m3.You shouldn't put ';' at the end of #includes, also.
Apart from that, you should be more specific when asking for help...
EDIT: Again you precede me, VernonDozier!
My fault, I'm slow in replying 'cause I get distracted
, btw yor answer is always more accurate ;-) Last edited by mrboolf; Nov 7th, 2008 at 1:02 pm.
C++ Syntax (Toggle Plain Text)
outfile<<name<<m1<<""<<m2<<""<<m3;
Where is the last line terminator ('\n') ? Your text file is ill-formed...
•
•
Join Date: Nov 2008
Posts: 5
Reputation:
Solved Threads: 0
well the final thing i want to ask
i made a program to read the results for the above program
This is the code i wrote
i made a program to read the results for the above program
This is the code i wrote
C++ Syntax (Toggle Plain Text)
// #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std ; int main ( ) { string name; int m1 ,m2, m3; float avg; ifstream input ("mark.txt",ios::app) ; input>>name>>m1>>m2>>m3; avg=m1/3.0+m2/3.0+m3/3.0; cout <<showpoint << fixed << setprecision (2); cout<<name<<" "<<avg<<endl; input.close; return 0 ; }
•
•
Join Date: Jan 2008
Posts: 3,832
Reputation:
Solved Threads: 501
•
•
•
•
well the final thing i want to ask
i made a program to read the results for the above program
This is the code i wrote
C++ Syntax (Toggle Plain Text)
// #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std ; int main ( ) { string name; int m1 ,m2, m3; float avg; ifstream input ("mark.txt",ios::app) ; input>>name>>m1>>m2>>m3; avg=m1/3.0+m2/3.0+m3/3.0; cout <<showpoint << fixed << setprecision (2); cout<<name<<" "<<avg<<endl; input.close; return 0 ; }
![]() |
Similar Threads
- program error for cd burner program (Windows NT / 2000 / XP)
- Help with a program's error (C++)
- Error Linking KeyLogger.exe (C++)
Other Threads in the C++ Forum
- Previous Thread: Writing an Operating System
- Next Thread: Function call problem
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int integer java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






