Jump to content

You guys are my last hope

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
rissvann

rissvann

    Newbie

  • Members
  • PipPip
  • 12 posts
Hi guys i need your help instantly

i am attending c programming course at my university & my teacher give me an assignment which i have to submit before end of this month & unfortunately i feel dumb to do that.

i am new in programming & stuck step after step:confused: :confused: :confused: .... please help me

He needs following output by using "For" loop

1)
*
**
***
****
*****
****
***
**
*

2)
123454321
1234 4321
123 321
12 12
1 1

3)
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

4) another programme is
take 3 inputs from user & tell which one is largest & smallest

Thank you very much

& Waiting till all gone

#2
xXHalfSliceXx

xXHalfSliceXx

    Speaks fluent binary

  • Moderators
  • 1,694 posts
LoL so you want us to do your HW for you 0_o ;) :D

Im sure someone will help you.

Posted Image
Posted Image


#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Are there any other rules? Can you use condition statements inside of the for?

You can do all of them by using two for loops each.
Example:
int p = 1;
for (int i=1;i<=10;i++) {
   int count = 0;
   if (i<=5) {
        count = i;
   }
   else {
        count = i - 5 - p;
        p++;
   }
   for (int s=1;s<=count; s++) {
        cout << "*";
   }
   cout << "\n";
}

Note, this is untested and probably doesn't work. Also, there is probably better ways to do this.

#4
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Could you at least introduce your self? just a line or two!

#5
xXHalfSliceXx

xXHalfSliceXx

    Speaks fluent binary

  • Moderators
  • 1,694 posts
Introductions can go here

http://forum.codecal.../introductions/

Posted Image
Posted Image


#6
rissvann

rissvann

    Newbie

  • Members
  • PipPip
  • 12 posts
Thanks for the reply
But definitely as i am new he will consider to do this work as simple as possible.

Yes, you are right, its not working & i again stucked but anyway load of thanks to you for helping me & giving me an idea.

I'll try to solve it at my capacity

Regards

Jordan said:

Are there any other rules? Can you use condition statements inside of the for?

You can do all of them by using two for loops each.
Example:

int p = 1;

for (int i=1;i<=10;i++) {

   int count = 0;

   if (i<=5) {

        count = i;

   }

   else {

        count = i - 5 - p;

        p++;

   }

   for (int s=1;s<=count; s++) {

        cout << "*";

   }

   cout << "\n";

}


Note, this is untested and probably doesn't work. Also, there is probably better ways to do this.


#7
rissvann

rissvann

    Newbie

  • Members
  • PipPip
  • 12 posts
no not actually, i just want help :)

xXHalfSliceXx said:

LoL so you want us to do your HW for you 0_o ;) :D

Im sure someone will help you.


#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Actually, it is C++ rather than C. You should be able to modify it very easy to C though.

#9
rissvann

rissvann

    Newbie

  • Members
  • PipPip
  • 12 posts
Aaaaaaah:o :confused:

I am fresh & doesnt know exactly how to handle it but dont worry am trying if able to do it, i'll tell u

Thanks :)

Jordan said:

Actually, it is C++ rather than C. You should be able to modify it very easy to C though.


#10
Cosmet

Cosmet

    Learning Programmer

  • Members
  • PipPipPip
  • 58 posts
I can't remember how I did it but I have the code lying somewhere around here for a problem just like this. I'll see if I can find it (I may have deleted it though).

#11
rissvann

rissvann

    Newbie

  • Members
  • PipPip
  • 12 posts
if you find it you'll be my hero;)

Cosmet said:

I can't remember how I did it but I have the code lying somewhere around here for a problem just like this. I'll see if I can find it (I may have deleted it though).