Diamond C Program using FOR loop
Make Diamond C using FOR Loops is a very Interesting Program that uses FOR Loops in a logical way. If you can Create Triangle as well as Inverse Triangle, then you can easily create Diamond very Quickly. It contains Nested Loops(Mean Loop Contains Loops). You can create large Triangle by Just Increasing Loops Initial Condition. You can Create Diamond By Simply Print Stars as it is. But You cannot Update or Modify in an Efficient Manner.
This Program is usually given in Examinations of Introduction to Programming. So it will be better for you to understand the Coding and Logic of Diamond.
Diamond C Program Output:

Diamond C Program Source Code:
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int i,f,s,t,l,o,h,j;
for(i=1; i<=4; i++)
{
for(f=4; f>i; f--)
{
cout<<" ";
}
for(s=1; s<=i; s++)
{
cout<<"*";
}
for(t=1; t<i; t++)
{
cout<<"*";
}
cout<<endl;
}
for(l=3; l>=1; l--)
{
for(o=4; o>l; o--)
{
cout<<" ";
}
for(h=1; h<=l; h++)
{
cout<<"*";
}
for(j=2; j<=l; j++)
{
cout<<"*";
}
cout<<endl;
}
getch();
}



“WORKS PERFECTLY IN TURBO C++”
“TO MAKE IT WORK IN DEV C++, JUST DELETE “RETURN 0;” FROM THE PROGRAM”
#include
#include
main()
{
int a,b,c,d;
d=0;
for(a=1;a<20;a=a+2)
{
for(c=d;c<40;c++)
printf(" ");
for(b=0;b0;a=a-2)
{
for(c=d;c<31;c++)
printf(" ");
for(b=1;b<a;b++)
printf("*");
printf("\n");
d–;
}
getch();
return 0;
}