1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Loop

Discussion in 'C++' started by sunveer, Aug 12, 2008.

  1. sunveer

    sunveer New Member

    Joined:
    Aug 12, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Write program using loops to produce the following output.

    output is:

    &&&&&&&
    &&&&&
    &&&
    &​
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Do it yourself
     
  3. aali

    aali New Member

    Joined:
    Jul 16, 2008
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    Riyadh
    .
    .
    .
    .
    int i=10;
    int j=0;
    while(j<i){
    while(i>0)
    {
    cout<<"&";
    i--;
    }
    j++;
    }
    PHP:
     
  4. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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++;}
    
     
  6. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  7. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    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:
    [​IMG]

    Hope It;s Done
     
  8. sunveer

    sunveer New Member

    Joined:
    Aug 12, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Thanx a lot
     
  9. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    U wellcome,

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

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    mmm, but why bother if you're going to do his homework for him anyway?
     
  11. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    no, u couldn't get my point. i want to tell him rather than making advanced coding try to start from simple one.
     
  12. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    You're right I don't get your point. These ARE simple coding tasks; there's nothing complicated about making squares, triangles etc of characters on a text mode screen. If the OP can't do these tasks then they won't be able to do more complicated ones, and the teacher won't be able to see why because they handed in a perfectly good basic task (that you wrote for him - you don't think the OP will credit you on that homework assignment do you?).
     
  13. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    i couldn't thing about that lolzzz :p
     
  14. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Maybe not, but lolzzz's aside (whatever they are, a semicomatose version of a lol?), you're not doing the OP any favours by handing him the answer to the question on a plate. It doesn't help him learn to program; if he's stuck it doesn't determine what he's stuck on and why, and it doesn't give him the explanation and the understanding he needs to progress. Far better to get over the not having a clue where to start at this point, rather than later on down the line in a monitored internet-free environment on a project that really matters to the final grade. The risk of handing in a plagiarised answer at this point are low, ok he'll get 10/10 for the task which may have no impact on the course but if he hands in a plagiarised solution to the final exam, penalties can be severe, from failing the module at least, to being kicked out of the establishment altogether as untrustworthy.
     
  15. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    Nice Lecture: really nice but sorry dude (wait first i lol on it hahahahhahaha)

    yes now come to the point.
    Topic Creator Request:
    Is there any thing written that give me idea about making this program or what is the concept behind them or any thing related,.
    jst a question and i make an answer that it.

    But I couldn't get the point of Exploit yours mind (sorry hahahahaha)
     
  16. Silcrome

    Silcrome New Member

    Joined:
    Jul 28, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    other than the moral reasons he might want to consider trying b/c i know my professors use to google bits of code from peoples programs to see if it pops up on forums.....if you get caught for this most schools will kick you out
     

Share This Page