well i wrote this code but it doesn't work and shows me bunch of
syntax if you can help me out finding them i would appreciate it!
the program should do simple calculations and no parenthesis are
allowed.so it is basically really simple but i am new at programming
and not sure about my code. Thank you!
here is my code:
#include <iostream>
#include <string>
#include <iostream.h>
using namespace std;
void main()
{
int b, c ; //declearing the variables
int reply;
int output;
cout << "Please enter 2 numbers" << endl;
cin >b >c;
cout <<"The Value of b: " << b << endl;
cout <<"The Value of c: " << c << endl;
cout << "please type '+' for abstraction, '-' for substraction,
'/' for division, and '*' for multipication"<< endl;
cin >reply >>;
if (reply= + ) {
output = b + c;
}
else if (reply = - ) {
output = b - c;
}
else if (reply = / ) {
output = b / c;
}
else if (reply = * ) {
output = b * c;
}
cout << "output: " << output << endl;
// This section stops the program 'flashing' off the screen.
cout << "Press q (or any other key) followed by 'Enter' to quit:
";
cin >reply;
return 0;
} 8 1537 ia*************@gmail.com wrote:
well i wrote this code but it doesn't work and shows me bunch of
syntax if you can help me out finding them i would appreciate it!
the program should do simple calculations and no parenthesis are
allowed.so it is basically really simple but i am new at programming
and not sure about my code. Thank you!
here is my code:
#include <iostream>
#include <string>
#include <iostream.h>
Loose this.
using namespace std;
void main()
main returns int.
{
int b, c ; //declearing the variables
Superfluous comment.
int reply;
Wrong type.
int output;
cout << "Please enter 2 numbers" << endl;
cin >b >c;
cout <<"The Value of b: " << b << endl;
cout <<"The Value of c: " << c << endl;
cout << "please type '+' for abstraction, '-' for substraction,
'/' for division, and '*' for multipication"<< endl;
cin >reply >>;
Too many >>
if (reply= + ) {
Quote the the characters.
output = b + c;
}
else if (reply = - ) {
output = b - c;
}
else if (reply = / ) {
output = b / c;
}
else if (reply = * ) {
output = b * c;
}
cout << "output: " << output << endl;
// This section stops the program 'flashing' off the screen.
cout << "Press q (or any other key) followed by 'Enter' to quit:
";
cin >reply;
return 0;
}
--
Ian Collins.
On Mar 22, 9:22 pm, Ian Collins <ian-n...@hotmail.comwrote:
ianenis.tiry...@gmail.com wrote:
well i wrote this code but it doesn't work and shows me bunch of
syntax if you can help me out finding them i would appreciate it!
the program should do simple calculations and no parenthesis are
allowed.so it is basically really simple but i am new at programming
and not sure about my code. Thank you!
here is my code:
#include <iostream>
#include <string>
#include <iostream.h>
Loose this.
using namespace std;
void main()
main returns int.
{
int b, c ; //declaring the variables
Superfluous comment.
int reply;
Wrong type.
int output;
cout << "Please enter 2 numbers" << endl;
cin >b >c;
cout <<"The Value of b: " << b << endl;
cout <<"The Value of c: " << c << endl;
cout << "please type '+' for abstraction, '-' for substraction,
'/' for division, and '*' for multipication"<< endl;
cin >reply >>;
Too many >>
if (reply= + ) {
Quote the the characters.
output = b + c;
}
else if (reply = - ) {
output = b - c;
}
else if (reply = / ) {
output = b / c;
}
else if (reply = * ) {
output = b * c;
}
cout << "output: " << output << endl;
// This section stops the program 'flashing' off the screen.
cout << "Press q (or any other key) followed by 'Enter' to quit:
";
cin >reply;
return 0;
}
--
Ian Collins.
so man how can i identify "reply" if you say int is not the right way?
On Mar 22, 9:22 pm, Ian Collins <ian-n...@hotmail.comwrote:
You're much nicer than I would be with these homework problems. ia*************@gmail.com wrote:
On Mar 22, 9:22 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>
>> int reply;
Wrong type.
>> if (reply= + ) {
I won't ask you again not to quote signatures, I'll just ignore you.
>
so man how can i identify "reply" if you say int is not the right way?
Well what type is it? Hint, what do you compare it against (and how are
you comparing)?
--
Ian Collins.
Tim H wrote:
On Mar 22, 9:22 pm, Ian Collins <ian-n...@hotmail.comwrote:
You're much nicer than I would be with these homework problems.
I think hints rather than answers are acceptable for homework questions.
Direct answers don't to the OP any favours.
--
Ian Collins.
<ia*************@gmail.comwrote:
well i wrote this code but it doesn't work and shows me bunch of
syntax if you can help me out finding them i would appreciate it!
the program should do simple calculations and no parenthesis are
allowed.so it is basically really simple but i am new at programming
and not sure about my code. Thank you!
here is my code:
#include <iostream>
#include <string>
#include <iostream.h>
Choose a form and stick with it. Either <iostream(preferred) or
<iostrream.hif your compiler won't accept the modern form.
using namespace std;
void main()
{
int b, c ; //declearing the variables
int reply;
int output;
cout << "Please enter 2 numbers" << endl;
cin >b >c;
cout <<"The Value of b: " << b << endl;
cout <<"The Value of c: " << c << endl;
cout << "please type '+' for abstraction, '-' for substraction,
'/' for division, and '*' for multipication"<< endl;
cin >reply >>;
if (reply= + ) {
You want the symbol + to be treated as a character constant. *Proper*
character constants are indicated like this:
if(reply = '+') {
This has repercussions elsewhere in your program.
Furthermore you want == which tests for equality, not = which is the
replacement operator in C++.
output = b + c;
}
else if (reply = - ) {
output = b - c;
}
else if (reply = / ) {
output = b / c;
}
else if (reply = * ) {
output = b * c;
}
cout << "output: " << output << endl;
// This section stops the program 'flashing' off the screen.
cout << "Press q (or any other key) followed by 'Enter' to quit:
";
cin >reply;
return 0;
}
Tim H wrote:
On Mar 22, 9:22 pm, Ian Collins <ian-n...@hotmail.comwrote:
You're much nicer than I would be with these homework problems.
Actually, he's OK here. He is apparently trying, and posting what he
did do, in accordance with FAQ 5.2. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: j.mandala |
last post by:
I created a simple link between two tables in a query. TableA has
Social Security numbers stored as Long Integer Data. (I imported this
table).
The Join is between these two fields
Table ...
|
by: Yodai |
last post by:
Hi all!
I have an int that comes with a value like 0x07fa and I have to turn it into
a float value of 204.2 decimal to display it.... if I try to divide it by
10 I get bogus numbers. I presume...
|
by: Ray |
last post by:
When a single-bit bitfield that was formed from an enum
is promoted/cast into an integer, does ANSI C say anything
about whether that integer should be signed or unsigned?
SGI IRIX cc thinks it is...
|
by: Brian Tkatch |
last post by:
An ORDER BY a simple-integer inside a FUNCTION, results in SQL0440N,
unless the FUNCTION expects an INTEGER as its parameter. For example:
DECLARE GLOBAL TEMPORARY TABLE A(A CHAR(1))
INSERT INTO...
|
by: sarathy |
last post by:
Hi,
What is integer promotion? How is it different from
arithmetic conversion?
Regards,
Sarathy
|
by: Cuthbert |
last post by:
Hi folks,
I am trying to find a more efficient way to count "How many bits are
'1' in a integer variable?".
I still have no idea to count the bits except using a loop and "if"
statements....
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first...
|
by: wazzup |
last post by:
My task is Create a program to read a simple integer expression and display the result. "Simple" means no parentheses are allowed and only the +, -, *, and / operators are allowed.
I think...
|
by: matevzb |
last post by:
I've ran into some fishy code that, at first glance, is buggy, but it
seems to work correctly
and none of the compilers I've tried (five so far, on various systems)
gives any warnings.
The code:...
|
by: copx |
last post by:
Can anyone point me to a simple, fast RRNG function to generate random ints
within a specified range? It is important that each value within the range
has the same probability (uniform...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |