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 1556 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.co mwrote:
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.co mwrote:
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.co mwrote:
>>
>> 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.co mwrote:
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.comwrot e:
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(prefe rred) or
<iostrream.hi f 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.co mwrote:
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 Field Data Type
------------------------------------------
TableA ClientNumA Long Integer
TableB CliNumB String
|
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 I have to make it decimal before
calculating, but I am not sure about it. Any light upon this simple (or it
seems to me so, at least) begginner problem?
TIA..
|
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 an unsigned integer, so I
see a +1 if the bit is set. Microsoft VC++ thinks it's
signed, so I see -1 if the bit is set.
Ex.
typedef enum {
|
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 SESSION.A VALUES ('a'), ('b')
CREATE FUNCTION A(A char(1)) RETURNS char(1) DETERMINISTIC NO EXTERNAL
ACTION RETURN A
SELECT A FROM SESSION.A ORDER BY A(1)
DROP FUNCTION A
DROP TABLE SESSION.A
|
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.
Could you know any other more efficient way?
Cuthbert
|
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
set of examples, after decoding the HTML FORM contents, merely
verifies the text within a field to make sure it is a valid
representation of an integer, without any junk thrown in, i.e. it
must satisfy the regular expression: ^ *?+ *$
If the...
|
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 expression would be Multiplications, then Division, then Addition and Subtraction.
My program gave me a wrong result after addition, take a look to my code you will understand. Please help me to develop this.
Here is my Code
|
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:
============================
#include <stdio.h>
void
fcn (char *str)
|
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 distribution).
I do not want to use the unreliable rand() function, but I do not want to
bloat my code with something as complex as MT either. I am just looking for
a short code snippet that I can copy without worrying about licensing.
The function should...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |