Previous in Forum: Visual Basics   Next in Forum: Dreamweaver Tutorial
Close
Close
Close
7 comments
Rate Comments: Nested
Anonymous Poster

C Language Problem

10/01/2010 4:29 PM

I need to write a 3n+1 problem in C language.

Add an if step to the algorithm such that the while loop is only executed if the input is

greater than 0. If the input is less than or equal to 0, then an error message should be

displayed instead.

Thanks for any idea?

Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Popular Science - Biology - New Member Hobbies - Musician - New Member APIX Pilot Plant Design Project - Member - New Member Hobbies - CNC - New Member Fans of Old Computers - ZX-81 - New Member

Join Date: Jan 2007
Location: Centurion, South Africa
Posts: 3921
Good Answers: 97
#1

Re: C Language Problem

10/01/2010 5:15 PM

Start with the HELLO WORLD example first and work yourselves up to the climax.

__________________
Never do today what you can put of until tomorrow - Student motto
Reply
Guru
Popular Science - Evolution - New Member Popular Science - Weaponology - New Member

Join Date: May 2006
Location: The 'Space Coast', USA
Posts: 11119
Good Answers: 918
#2

Re: C Language Problem

10/01/2010 6:25 PM

Sounds like a homework problem.

I don't want to do the assignment for you, but if you can show us what you have so far and then ask a specific question, there will be people willing to help round out your education by guiding you.

Reply
Guru
Technical Fields - Technical Writing - New Member Engineering Fields - Piping Design Engineering - New Member

Join Date: May 2009
Location: Richland, WA, USA
Posts: 21017
Good Answers: 795
#3

Re: C Language Problem

10/01/2010 7:43 PM

This isn't C language, but just do pretty much what you already said:

If (number) ≤ 0, then print "Invalid input. Please enter an integer greater than 0."

Or something like that, translated into C.

(Interesting problem, by the way, if it's the one I'm thinking of. Try 27.)

__________________
In vino veritas; in cervisia carmen; in aqua E. coli.
Reply
Participant

Join Date: Aug 2010
Posts: 3
#4

Re: C Language Problem

10/02/2010 4:50 AM

if (input>0)

{

do

{

set of instructions;

}

while(condition);

}

else

if (input<=0)

{

printf(" error message");

}

Hope that helps!!! the content of the error message to be at your discretion

Reply
Anonymous Poster
#5

Re: C Language Problem

10/04/2010 3:55 PM

What??!! No one wants to solve a homework problem for Guest? Shame on you all. Are you really expecting someone to use their own sweat in this day and age? Get serious! "Cheating" on tests, homework and resumes is the "in" thing and has been for many, many years now. It's all about landing that gravy-train job through whatever means necessary.

Am I being too cynical?

Reply Off Topic (Score 5)
Guru
Popular Science - Weaponology - New Member Safety - ESD - New Member Hobbies - Fishing - New Member

Join Date: Sep 2006
Location: Near Frankfurt am Main, Germany. 50.390866N, 8.884827E
Posts: 17996
Good Answers: 200
#6
In reply to #5

Re: C Language Problem

10/08/2010 3:20 PM

NO!

__________________
"What others say about you reveals more about them, than it does you." Anon.
Reply Score 1 for Off Topic
Participant

Join Date: Aug 2010
Posts: 3
#7
In reply to #5

Re: C Language Problem

10/08/2010 8:06 PM

I just did spoon feed you!!!

Reply Off Topic (Score 5)
Reply to Forum Thread 7 comments
Copy to Clipboard

Users who posted comments:

aguyplaya (2); Andy Germany (1); Anonymous Hero (1); Anonymous Poster (1); Hendrik (1); Tornado (1)

Previous in Forum: Visual Basics   Next in Forum: Dreamweaver Tutorial

Advertisement