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
You guys are my last hope
Started by rissvann, Nov 27 2006 07:56 AM
10 replies to this topic
#1
Posted 27 November 2006 - 07:56 AM
|
|
|
#2
Posted 27 November 2006 - 08:01 AM
#3
Guest_Jordan_*
Posted 27 November 2006 - 08:44 AM
Guest_Jordan_*
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:
Note, this is untested and probably doesn't work. Also, there is probably better ways to do this.
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
Posted 27 November 2006 - 10:46 AM
Could you at least introduce your self? just a line or two!
#5
Posted 27 November 2006 - 12:06 PM
#6
Posted 28 November 2006 - 02:22 AM
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
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:
Note, this is untested and probably doesn't work. Also, there is probably better ways to do this.
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
Posted 28 November 2006 - 02:39 AM
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.
Im sure someone will help you.
#8
Guest_Jordan_*
Posted 28 November 2006 - 05:52 AM
Guest_Jordan_*
Actually, it is C++ rather than C. You should be able to modify it very easy to C though.
#9
Posted 28 November 2006 - 06:06 AM
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 :)
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
Posted 28 November 2006 - 06:12 AM
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
Posted 28 November 2006 - 08:13 AM
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).


Sign In
Create Account


Back to top











