c program to print diamond pattern, C Program to Print Diamond in C , Diamond Shape in C Language, C Assignment to print Diamond shape in C
#include
int main()
{
int n, c, k, space = 1;
printf("Enter number of rows\n");
scanf("%d", &n);
space = n - 1;
for (k = 1; k <= n; k++)
{
for (c = 1; c <= space; c++)
printf(" ");
space--;
for (c = 1; c <= 2*k-1; c++)
printf("*");
printf("\n");
}
space = 1;
for (k = 1; k <= n - 1; k++)
{
for (c = 1; c <= space; c++)
printf(" ");
space++;
for (c = 1 ; c <= 2*(n-k)-1; c++)
printf("*");
printf("\n");
}
return 0;
}
OUTPUT :
*
***
*****
***
*
Related Links :
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
getch ();
}
Please provide a c program for below pattern:
ReplyDelete12345
12 45
1 5
12 45
12345
#include
Deletemain()
{
int i,j,k=1;
for(i=1;i<=5;i++)
{
k=1;
for(j=1;j<=5;j++)
{
if((i==2 && j==3) || (i==4 && j==3))
{ printf(" "); }
else if(i==3 && j==2)
{
j=k=4;
printf(" ");
}
else
{ printf("%d",k); }
k++;
}
printf("\n");
}
In the comment published, in middle row 5 should come extreme end...sorry for mistake
ReplyDeleteThis comment has been removed by the author.
ReplyDelete