Loop

sunveer's Avatar, Join Date: Aug 2008
Light Poster
Write program using loops to produce the following output.

output is:

&&&&&&&
&&&&&
&&&
&
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Do it yourself
0
aali's Avatar, Join Date: Jul 2008
Go4Expert Member
.
.
.
.
int i=10;
int j=0;
while(j<i){
while(i>0)
{
cout<<"&";
i--;
}
j++;
}[PHP]
0
faizulhaque's Avatar, Join Date: May 2008
Skilled contributor
lolzzzz
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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++;}
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.
0
faizulhaque's Avatar, Join Date: May 2008
Skilled contributor
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
0
sunveer's Avatar, Join Date: Aug 2008
Light Poster
Thanx a lot
0
faizulhaque's Avatar, Join Date: May 2008
Skilled contributor
U wellcome,

but suggestion to u,
u have to try with simple coding.
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
mmm, but why bother if you're going to do his homework for him anyway?