Loop

Light Poster
12Aug2008,16:52   #1
sunveer's Avatar
Write program using loops to produce the following output.

output is:

&&&&&&&
&&&&&
&&&
&
Go4Expert Founder
12Aug2008,20:48   #2
shabbir's Avatar
Do it yourself
Go4Expert Member
13Aug2008,12:30   #3
aali's Avatar
.
.
.
.
int i=10;
int j=0;
while(j<i){
while(i>0)
{
cout<<"&";
i--;
}
j++;
}[PHP]
Skilled contributor
13Aug2008,13:28   #4
faizulhaque's Avatar
lolzzzz
Mentor
13Aug2008,14:55   #5
xpi0t0s's Avatar
Here you go. I've indented it to make it easy to see what's going on:
Code:
int main()
{
	char *str01="I'm a cheating smeghead!!!\0ebahhhaagfaaghhfhfgfiehdhihbadijidgjhbhchchbheahabae";
	for (int i='a';i<='z'; putchar
	(
		(
			str01[i-'a']+(25-i+2*'a')+
			i-'a'-116-(((str01+27)
			[
				(i-'a')*2]-'a')*10+((str01+27)[(i-'a')*2+1
			]
			-'a')))=='#'?10:(str01[i-'a'
		]
		+(25-i+2*'a')+i-'a'-116-(((str01+27)
		[
			(i-'a')*2]-'a')*10+((str01+27)[(i-'a')*2+1
		]
		-'a')))
	)
)
i++;}
Mentor
13Aug2008,15:00   #6
xpi0t0s's Avatar
Hmm, it probably won't work as is; I can't seem to shift those two spaces from the middle of str01. Shabbir, does the forum split long words? If so how about NOT doing that in code blocks?

str01 after the zero should be "ebahh haagf aaghh fhfgf iehdh ihbad ijidg jhbhc hchbh eahab ae", with spaces inserted after every five for the forum's benefit; remove these extra spaces before running the program otherwise it just won't work.
Skilled contributor
13Aug2008,15:32   #7
faizulhaque's Avatar
Take That Code:
Code:
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
for (int a=8,v=1;v<4,a>0;v++)
{
	for(int b=1;b<a;b++)
	printf("&");

	printf("\n");

	for (int x=0;x<v;x++)
	printf(" ");

a=a-2;
}
getch();
}
Snap:


Hope It;s Done
Light Poster
14Aug2008,15:55   #8
sunveer's Avatar
Thanx a lot
Skilled contributor
14Aug2008,20:32   #9
faizulhaque's Avatar
U wellcome,

but suggestion to u,
u have to try with simple coding.
Mentor
14Aug2008,20:48   #10
xpi0t0s's Avatar
mmm, but why bother if you're going to do his homework for him anyway?