0% found this document useful (0 votes)
43 views3 pages

C Programs

This document contains code for a C program that prints out a star pattern. It uses nested for loops and print statements to output incrementing rows of stars with leading spaces that form the shape of a diamond. The outer for loops iterate from 0 to 10 to print the top and bottom halves of the diamond. The inner for loops handle the printing of spaces and stars with counters that vary on each row.

Uploaded by

Sreejith PB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

C Programs

This document contains code for a C program that prints out a star pattern. It uses nested for loops and print statements to output incrementing rows of stars with leading spaces that form the shape of a diamond. The outer for loops iterate from 0 to 10 to print the top and bottom halves of the diamond. The inner for loops handle the printing of spaces and stars with counters that vary on each row.

Uploaded by

Sreejith PB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Star program

#include<stdio.h>

#include<conio.h>

Void main()

Clrscr();

Int i,j,k=10,l=10;

For(i=0;i<=10;i++)

K=l;

For( ;k>=0;k--)

Printf(“\t”);

For(j=0;j<=i;j++)

Printf(“* \t”);

Printf(“\n”);

L=l-1;

Getch();

Otput:::::::

* *

* * *

DIAMOND PROGRAM
#include<stdio.h>
#include<conio.h>
Void main()
{
Clrscr();
Int i,j,k=10,l=10;
For(i=0;i<=10;i++)
{
K=L;
For( ;k>=0;k--)
Printf(“ “);
For(j=0;j<=i;j++)
{
Printf(“* “);
}
Printf(“\n”);
L=L-1;
}
K=1;
L=1;
For(i=1;i<=10;i++)
{
K=L
For(k=0;k<=i;k++)
Printf(“ “);
For(j=10;j>=i;j--)
{
Printf(“* “);
}
Printf(“\n”);
L=L+1;
}
Getch();
}

You might also like