Click to See Complete Forum and Search --> : Please help with this code
waheedrafiq
December 27th, 2002, 06:02 AM
I have leart C programming in pass and then i stop once i pass my exam and of course you know what happends next you forget it !
i am trying to learn C++ and therefore bought this book C++ for Dummies
i am getting some erros with this code line 37 it says string not termiated now i have try alsort of things but no good.
/ This is a PA from what i have learnt chap01 to chap 04
//this program will do addition , times, sharing , subtractions.
#include <stdio.h>
#include <iostream.h>
int main()
{
int num1,num02,total;
float num1f,num2f,totalf;
cout <<"*************************************"<"\n";
cout <<"** Dynex Basic Maths Program **"<"\n";
cout <<"*************************************"<"\n";
cout <<" ************* "<\n";
cout <<" **** "<"\n";
cout <<" ** "<"\n";
cout <<"\n";
cout <<"Enter the first digit:"<<"\n";
cin >> num1;
cout <<"\n";
cout <<"Now enter the second digit:"<<"\n";
cin >> num2;
cout <<"\n";
total = num1 + num2;
cout <<" Your total sum is:"
cout << total;
cout <<"\n";
cout <<"*********************************"<< "\n";
cout <<" Programs ends "<< "\n";
// this is were the error happens ? cout <<"*********************************"<< "\n";
return 0;
}
please help me
Doctor Luz
December 27th, 2002, 06:09 AM
If the code is this
cout <<" Programs ends "<< "\n";
// this is were the error happens ? cout <<"*********************************"<< "\n";
try this
cout <<" Programs ends "<< "\n";
// this is were the error happens ? cout
cout <"*********************************"<< "\n";
PaulWendt
December 27th, 2002, 09:52 AM
I ran your code through my compiler and fixed all of the errors
that cropped up. Most of them were simple typos [putting <
instead of << for the extraction stream operator or not enclosing
a string inside double quotes]. You should use the headers that
I specified, however. The old header files that you used before
are deprecated in the standard and may be in older text books,
but they are not guaranteed to exist in the real world [though
they will probably exist for years].
// This is a PA from what i have learnt chap01 to chap 04
//this program will do addition , times, sharing , subtractions.
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int num1,num2,total;
float num1f,num2f,totalf;
cout <<"*************************************"<<"\n";
cout <<"** Dynex Basic Maths Program **"<<"\n";
cout <<"*************************************"<<"\n";
cout <<" ************* "<<"\n";
cout <<" **** "<<"\n";
cout <<" ** "<<"\n";
cout <<"\n";
cout <<"Enter the first digit:"<<"\n";
cin >> num1;
cout <<"\n";
cout <<"Now enter the second digit:"<<"\n";
cin >> num2;
cout <<"\n";
total = num1 + num2;
cout <<" Your total sum is:";
cout << total;
cout <<"\n";
cout <<"*********************************"<< "\n";
cout <<" Programs ends "<< "\n";
// this is were the error happens ?
cout <<"*********************************"<< "\n";
return 0;
}
--Paul
ashishd
December 28th, 2002, 01:58 AM
I also tried to remove all errors (very simple)
the code is:
// This is a PA from what i have learnt chap01 to chap 04
//this program will do addition , times, sharing , subtractions.
#include <stdio.h>
#include <iostream.h>
int main()
{
int num1,num2,total;
float num1f,num2f,totalf;
cout <<"*************************************"<<"\n";
cout <<"** Dynex Basic Maths Program **"<<"\n";
cout <<"*************************************"<<"\n";
cout <<" ************* "<<"\n";
cout <<" **** "<<"\n";
cout <<" ** "<<"\n";
cout <<"\n";
cout <<"Enter the first digit:"<<"\n";
cin >> num1;
cout <<"\n";
cout <<"Now enter the second digit:"<<"\n";
cin >> num2;
cout <<"\n";
total = num1 + num2;
cout <<" Your total sum is:";
cout << total;
cout <<"\n";
cout <<"*********************************"<< "\n";
cout <<" Programs ends "<< "\n";
// this is were the error happens ?
cout <<"*********************************"<< "\n";
return 0;
}
waheedrafiq
December 28th, 2002, 05:21 AM
My god i never even dream of getting a reply back so thanks to all of you who have help me with this
can any of you warrirors help or point me to the right directions
i am currently using rhide version 1.4 which came with this dummies book is this a good complier or can i find a better one for free.
many thanks the code works and i have leart something new today .
Paul McKenzie
December 28th, 2002, 07:13 AM
Originally posted by waheedrafiq
My god i never even dream of getting a reply back so thanks to all of you who have help me with this
can any of you warrirors help or point me to the right directions
i am currently using rhide version 1.4 which came with this dummies book is this a good complier or can i find a better one for free.
many thanks the code works and i have leart something new today . If the compiler still uses old headers such as <iostream.h> instead of the standard <iostream>, then you better get another (more modern) compiler.
Regards,
Paul McKenzie
youngmj
December 28th, 2002, 03:42 PM
There are several good "free" (still be sure to read and honor the licenses, though!) compilers and IDEs available on the web. One that is quickly becoming my favorite is Dev-C++ (available at www.bloodshed.net) - I've dabbled with the latest beta with the latest Mwing CRT library for some smaller, educational projects, and even though the IDE is still somewhat quirky, the gcc compiler is very good.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.