#Functions, Scan, and Conditionals project
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
I think my middle part is all correct
but it's my first and last part that's tripping me
nothing appears on the terminal when i try to run it
!f
Internal error while running !f
@visual saffron this is the new thread
Yep, I am already looking at the code.
ok thx
I think your understanding of a programming language may be a little "off".
oh
A function may call another function.
Which in turn may call another function.
But that does not mean that all functions in a program must be "daisy-chained".
Your main() calls welcomeScreen().
welcomeScreen() then calls intermediateCalculator() and then prints "Thank You".
It doesn't quite work, and you could make it work like that.
But it's not quite right.
Function welcomeScreen() should just print a message to the screen.
When that's done, the function returns to main().
Then it should call intermediateCalculator().
Whoaahh!
I am so sorry.
Ignore everything I said.
You are just following instructions.
Yeah, sorry.
I cut a corner and didn't read those.
Bit me in the [redacted], as usual.
it's alright it's alright
Your immediate issue is easily solved
void welcomeScreen (void) {
printf("\nWelcome to the Intermediate Calculator~!\n");
intermediateCalculator();
printf("Thank you\n");
}
that's the last part right?
No, the call to intermediateCalculator().
Compare with yours.
void welcomeScreen (void) {
printf("\nWelcome to the Intermediate Calculator~!\n");
void intermediateCalculator (void);
printf("Thank you\n");
}
I think you just copy and pasted the prototype and used it as a call to the function.
right the void in the intermediate calcualtor is gone
ahh yea...
umm ok
i have encounteredd a problem
it all works fine
but
The outcome for the expression came out to be {finalOutcome}
it says this
instead of actually giving the final outcome
What do you enter?
(ik, probably in one of those screenshots)
Welcome to the Intermediate Calculator~!
Welcome to the Intermediate Calculator~!
You will be providing four numbers and three operators!
The numbers must be integers and the operators must be add, subtract, multiply, divide, or remainder!
Please enter the expression below:
1 * 3 * 5 + 4
The outcome for the expression came out to be {finalOutcome}
Thank you
this is what i get
else {
if (operator_two == '+'){
finalOutcome = firstSecondOutcome + thirdFourthOutcome;
}
else if (operator_two == '-'){
finalOutcome = firstSecondOutcome - thirdFourthOutcome;
}
else if (operator_two == '*'){
finalOutcome = firstSecondOutcome * thirdFourthOutcome;
}
else if (operator_two == '/'){
finalOutcome = firstSecondOutcome / thirdFourthOutcome;
}
else {
finalOutcome = firstSecondOutcome % thirdFourthOutcome;
}
}
printf("The outcome for the expression came out to be {finalOutcome}\n");
}
printf("The outcome for the expression came out to be %d\n", finalOutcome);
@shadow marsh Has your question been resolved? If so, type !solved :)
@shadow marsh
From the assignment:
If operator_one is *, /, or %
You are using && which is AND.
You want || for OR.
And also:
If firstOperatorFlag is 2 and secondOperatorFlag is 2
You are using , which is not AND.
You want && here.
(neither emphasis mine)
Welcome to the Intermediate Calculator~!
Welcome to the Intermediate Calculator~!
You will be providing four numbers and three operators!
The numbers must be integers and the operators must be add, subtract, multiply, divide, or remainder!
Please enter the expression below:
1 * 3 * 5 + 4
firstSecondOutcome = 1 * 3 = 3
firstSecondThirdOutcome = 3 * 5 = 15
finalOutcome[1] = 15 + 4 = 19
The outcome for the expression came out to be 19
Thank you
And
Welcome to the Intermediate Calculator~!
Welcome to the Intermediate Calculator~!
You will be providing four numbers and three operators!
The numbers must be integers and the operators must be add, subtract, multiply, divide, or remainder!
Please enter the expression below:
4 + 5 * 6 / 10
secondThirdOutcome = 5 * 6 = 30
secondThirdFourthOutcome = 30 / 10 = 3
finalOutcome[2] = 4 + 3 = 7
The outcome for the expression came out to be 7
Thank you
You were very close.
Just those two bugs I mentioned.
oh, ok
ok wait
so the code i have right now is
this is the code I have
but it doesn't work
it says there is an error
@visual saffron
What’s the error message
Calculator.c:179:48: error: expression is not assignable
if (firstOperatorFlag = 2&& secondOperatorFlag = 2){
~~~~~~~~~~~~~~~~~~~~~~ ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
to check for equality you use ==
ok
well
there seems to be a problem with my middle code
Welcome to the Intermediate Calculator~!
You will be providing four numbers and three operators!
The numbers must be integers and the operators must be add, subtract, multiply, divide, or remainder!
Please enter the expression below:
3 * 4 + 5 * 5
The outcome for the expression came out to be -1
Thank you
i'm pretty sure 3 4 + 55
is not -1
what is the problem here?
@shadow marsh Has your question been resolved? If so, type !solved :)