5 Replies - 1402 Views - Last Post: 08 October 2011 - 01:53 PM Rate Topic: -----

#1 TwidgetUSN  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-October 11

Help with a WHILE loop

Posted 08 October 2011 - 11:25 AM

Hello everyone.
I am working on a homework assignment and I could use some help. I don't want the answer just given to me but any help/nudge/advice would help.
We have been learning pseudocode but for this assignment we're asked to not use pseudo. We haven't learned C++, Java or C# yet so it's just very basic programming language...nothing that is actually executable. We only need the snippet of code; no full program and no declaring variables.
The question is:

Quote

Write a WHILE loop that squares each number starting with 1 and ends when the square equals 49


So far this is what I've figured out.
int = 1
while squareNum <> 49
     int * int = squreNum
	     int = int + 1


Am I on the right track? Where do I go next?
Any help would be appreciated :)

This post has been edited by TwidgetUSN: 08 October 2011 - 11:33 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Help with a WHILE loop

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5675
  • View blog
  • Posts: 12,192
  • Joined: 02-June 10

Re: Help with a WHILE loop

Posted 08 October 2011 - 11:57 AM

Well if you haven't learned any actual coding language then anything you write is going to be some flavor of pseudo code. Simply has to be and stands to reason. With that in mind what you have doesn't seem off track to me.

How long have you been in this class and they haven't actually taught any real coding? If its more than 3 days then they are doing their best to stretch out the course for maximum tuition income.

You would have started actual coding in C# around chapter 2 of any $20 self-teaching book. Just because you have a course text book doesn't make it illegal to buy other books or use internet tutorials to learn faster than they are going.


Resources, references and suggestions for new programmers. - Updated Sep 2011
Spoiler

This post has been edited by tlhIn`toq: 08 October 2011 - 11:58 AM

Was This Post Helpful? 1
  • +
  • -

#3 TwidgetUSN  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-October 11

Re: Help with a WHILE loop

Posted 08 October 2011 - 12:53 PM

It is a programming essentials class and we are in week four. We've covered the basics with classes, declaring variables, IF statements, loops and arrays. Here's an example of the most in depth code we've covered so far.
if dep = 0 then
     count0 = count0+1
else
     if dep = 1 then
etc etc etc

Nothing deep yet so it's really hard to find help online because most guides I've found cover stuff we haven't even reached yet and we're not allowed to use anything past our level of learning.
Was This Post Helpful? 0
  • +
  • -

#4 TwidgetUSN  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-October 11

Re: Help with a WHILE loop

Posted 08 October 2011 - 01:08 PM

I think I've figured it out. I just needed someone to let me know if I'm on the right track :)
How does this look?

int = 1
while squareNum <> 49
     int * int = squareNum
     int = int + 1
     output  int, “squared is”, squareNum
endwhile
output	int, “squared is”, squareNum
output “This program will only square up to 7 squared which is 49”

This post has been edited by TwidgetUSN: 08 October 2011 - 01:09 PM

Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5675
  • View blog
  • Posts: 12,192
  • Joined: 02-June 10

Re: Help with a WHILE loop

Posted 08 October 2011 - 01:28 PM

FOUR WEEKS... and you haven't actually written any working code in a known language? Frak me! Sounds like a total rip off in my mind.

ANY self-teaching book available at Amazon or Fry's Electronics would have had you building applications long ago.


Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5 is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

Just order it and go through it. You will be slam dunking this course in a week.
Was This Post Helpful? 0
  • +
  • -

#6 TwidgetUSN  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-October 11

Re: Help with a WHILE loop

Posted 08 October 2011 - 01:53 PM

I will definitely take a look at that book, thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1