Program of Loop

Discussion in 'C' started by sunveer, Aug 14, 2008.

  1. sunveer

    sunveer New Member

    Joined:
    Aug 12, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Q Use for loop to print the following output:




    &
    & &
    & &
    & &
    & &
    & &
    & & & & & & & & & & &​
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How far have you got and where are you stuck?
    We won't write the code for you, unless you're willing to pay the going rate.
     
  3. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    210
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    http://www.google.com
    Codings:
    Code:
    #include<stdio.h>
    #include<conio.h>
    void main(void)
    {
    clrscr();
    for (int a=0;a<8;a++)
    {
    	if (a==0)
    	{
    	for (int b=0;b<1;b++)
    	printf("&\n");
    	}
    	else if (a>0 && a<7)
    	{
    	for (int c=0;c<1;c++)
    	printf("& &\n");
    	}
    	else if (a==7)
    	{
    	for(int d=0;d<11;d++)
    	printf("& ");
    	}
    }
    getch();
    }
    
    I suppose it couldn;t made without conditions.

    Prof:
    [​IMG]
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice