Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Loop (http://www.go4expert.com/forums/loop-t12881/)

sunveer 12Aug2008 16:52

Loop
 
Write program using loops to produce the following output.

output is:

&&&&&&&
&&&&&
&&&
&

shabbir 12Aug2008 20:48

Re: Loop
 
Do it yourself

aali 13Aug2008 12:30

Re: Loop
 
.
.
.
.
int i=10;
int j=0;
while(j<i){
while(i>0)
{
cout<<"&";
i--;
}
j++;
}[PHP]

faizulhaque 13Aug2008 13:28

Re: Loop
 
lolzzzz

xpi0t0s 13Aug2008 14:55

Re: Loop
 
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++;}


xpi0t0s 13Aug2008 15:00

Re: Loop
 
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.

faizulhaque 13Aug2008 15:32

Re: Loop
 
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:
http://www.imagehostingsite.com/imag...gajgym4o3z.jpg

Hope It;s Done

sunveer 14Aug2008 15:55

Re: Loop
 
Thanx a lot

faizulhaque 14Aug2008 20:32

Re: Loop
 
U wellcome,

but suggestion to u,
u have to try with simple coding.

xpi0t0s 14Aug2008 20:48

Re: Loop
 
mmm, but why bother if you're going to do his homework for him anyway?


All times are GMT +5.5. The time now is 13:24.