Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Saturday, January 29, 2011

C PROGRAM FOR DIAMOND

#include<stdio.h>
int main()
{
    int counter,x,y,z;
    int count,a,b,c,input;
    printf("PLEASE ENTER the width");   
    scanf("%d",&input);
    counter=0;
    for(x=input;x>=1;x--)
    {
        for(y=1;y<=x;y++)
        {
            printf(" ");
        }
                counter=counter+1;
            for(z=1;z<=counter;z++)
                {printf("* ");}
                printf("\n");}
    count=input;
    for(a=1;a<=input;a++)
    {
        printf(" ");
        for(b=1;b<=a;b++)
        {
            printf(" ");
        }
        count=count-1;
        for(c=1;c<=count;c++)
        {
            printf("* ");
        }
        printf("\n");
    }
return 0;
}

No comments:

Post a Comment

Related Posts with Thumbnails