C and C++ Programs
It Contains C And C++ programs that are useful for students it includes C programs for data structures
Diamond In C
/* C program to display a diamond using arrays */
#include< iostream.h>
#include< conio.h>
void main()
{
int i,j;
clrscr();
int no;
cout< < "Enter A Value";
cin>>no;
for(i=no;i>=1;i--)
{
cout< < endl;
for(int k=1;k< =i;k++)
cout< < " ";
for(j=i;j< =no;j++)
cout< < "*";
for(j=i;j< no;j++)
cout< < "*";
}
//SECOND PART
for(i=no;i>=1;i--)
{
cout< < endl;
cout< < " ";
for(int k=no;k>=i;k--)
cout<<" ";
for(j=i-1;j>=1;j--)
cout< < "*";
for(j=i-1;j>1;j--)
cout<<"*";
}
getch();
}
#include< iostream.h>
#include< conio.h>
void main()
{
int i,j;
clrscr();
int no;
cout< < "Enter A Value";
cin>>no;
for(i=no;i>=1;i--)
{
cout< < endl;
for(int k=1;k< =i;k++)
cout< < " ";
for(j=i;j< =no;j++)
cout< < "*";
for(j=i;j< no;j++)
cout< < "*";
}
//SECOND PART
for(i=no;i>=1;i--)
{
cout< < endl;
cout< < " ";
for(int k=no;k>=i;k--)
cout<<" ";
for(j=i-1;j>=1;j--)
cout< < "*";
for(j=i-1;j>1;j--)
cout<<"*";
}
getch();
}
Related Articles
Comments
Be the first to leave a comment!
About the Author
From Our Partners
People in Pictures
Top Geek Articles
|
Celebrities on the Phone
Cell phones are to celebrities like bats are to baseball: no one runs too far without them.
|
|
Why every guy should buy their girlfriend Wii Fit.
Gratuitous...
|
|
Hot Geeks -- The Sexiest Geeky Girls
These girls are gorgeous AND they'll play Warcraft with you. Doesn't get much better than that.
|




