hello dani........

plz help to get the following output using C language(array)

using one nested for loop

*******
*****
***
*
***
*****
*******
plz...........help........quick

hplz...........help........quick

Um. To start, please read the Announcement on homework in the forums. This program is very, very easy to write, and shouldn't take too much for you to do if you just read your C programming book. Write something. Then, if you need help, post your code here, and we'll help you troubleshoot your code.

Secondly, NEVER request members of a forum to respond "quick", or quickly. Doing so implies that your problem is more important than someone else's who was here before you; therefore, it's considered to be very rude. On the forums, people are responded to in the order they posted, or when someone knows the answer.

/**************************************************************************
**************************************************************************

A C++ Program to print a diamond in the following pattern.

*
                   * *
                  * * *
                 * * * *
                * * * * *
                 * * * *
                  * * *
                   * *
                    *

( using nested for loop ).

main()
    {
       clrscr();

       cout<<"\n ********* Diamond  *********\n"<<endl;

       int x_1=19;
       int y_1=5;

       for(int count_1=1;count_1<=5;count_1++)
	  {
	     gotoxy(x_1,y_1);

	     for(int count_2=1;count_2<=count_1;count_2++)
		cout<<"* ";

	     x_1--;
	     y_1++;

	     cout<<endl;
	  }


       int x_2=16;
       int y_2=10;

       for(int count_3=5;count_3>1;count_3--)
	  {
	     gotoxy(x_2,y_2);

	     for(int count_4=count_3;count_4>1;count_4--)
		cout<<"* ";

	     x_2++;
	     y_2++;

	     cout<<endl;
	  }
       getch();
       return 0;
    }

Now Change and Solve ur Problem

commented: 3 years too late! -3
commented: Don't feed the bears -1

Um. To start, please read the Announcement on homework in the forums. This program is very, very easy to write, and shouldn't take too much for you to do if you just read your C programming book. Write something. Then, if you need help, post your code here, and we'll help you troubleshoot your code.

Secondly, NEVER request members of a forum to respond "quick", or quickly. Doing so implies that your problem is more important than someone else's who was here before you; therefore, it's considered to be very rude. On the forums, people are responded to in the order they posted, or when someone knows the answer.

c syntax:

#include<stdio.h>
void main()
{
int i,j,k,h;
clrscr();
for(i=0,k=0;i<7;i++,k+=2)
{
if(i==4)
k=0;
if(i<4)
for(j=6-k;j>=0;j--)
printf("*");
else
for(j=2+k;j>=0;j--)
printf("*");
printf("\n");
}
}

iam new member of this community.reply me
byeeeeeeee.

commented: 4 YEARS too late, uses void main, no code tags - your grade: F -6
commented: Read previous posts? Definitely a good idea. +4
#include<stdio.h>
main()
{

     int i,n;
     printf("\nEnter the no of lines:");
     scanf("%d",&n);
     for(i=0;i<2*n;i++)
     {
            for(j=i;j<n;j++)
            {printf("*");}
            printf ("\n");
           if(j>=n)
            {
                   for(j=n;j<i;j++)
                    {printf("*");}
                    printf("\n");
              }
     }
}
commented: Read the whole thread - now why did you post this? -4
commented: alt.coders.flunk.flunk.flunk -6
commented: it is really encouraging support +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.