• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

programming problem

mOeeOm

Platinum Member
I know, its simple to some of you guys, but please help, this is a forced course for engineering and I will never have to take it against after first year.

Write a user-defined function that computes the reduced sum of an integer. The
programmer should allow the user to input this integer. After outputting the
reduced sum, prompt the user to enter zero to exit or a non-zero integer to
continue. You must use the do-while loop.
Function prototype: int reducedSum(int value);
Example: Reduced sum of 124 is 1+2+4 = 7


This is the code I got so far for it, the error says:

''Error E@376 problem1.c 18: Do-while statement missing { in function main
*** 1 errors in compile ***

When I go to line 18, and add {, I get a lot more errors...help?
 
Quick look:

You have defined the prototype of the reducedsum.
Where is the body of this function?
You should never embedd the body of the function within another function (main).

Fix those items, rebuild and then attempt on your own to analyze the errors.

Also post the error messages.
 
Put statements in parantheses and fix the while statement.

do...while
entered / 10 >= 1;

=

while ((entered / 10) > =1) {
operations
}

Plus there is no implementation of int reducedSum(int value);.

No offense at all man but review this tutorial. It will be very beneficial to you. Just trying to help.
 
Originally posted by: xtknight
Put statements in parantheses and fix the while statement.

do...while
entered / 10 >= 1;

=

while ((entered / 10) > =1) {
operations
}

Plus there is no implementation of int reducedSum(int value);.

No offense at all man but review this tutorial. It will be very beneficial to you. Just trying to help.

ya any help appreciated, I never took programming in HS, they making us take it for first year engineering...so I'm VERY lost.
 
Originally posted by: mOeeOm
Originally posted by: xtknight

No offense at all man but review this tutorial. It will be very beneficial to you. Just trying to help.

ya any help appreciated, I never took programming in HS, they making us take it for first year engineering...so I'm VERY lost.
Some of us did not even have computers in HS.
Sliderule 101😱

 
Back
Top