Friday, 31 January 2014

Printing a Diamond in C++ using Aesterics.

Posted by viralnom  |  at  22:11 No comments



  1. #include<iostream>
  2.  
  3. #include<cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8.  
  9. {
  10.  
  11. int i=0, j=0, NUM=3;
  12.  
  13. for(i=-NUM; i<=NUM; i++)
  14.  
  15. {
  16.  
  17. for(j=-NUM; j<=NUM; j++)
  18.  
  19. {
  20.  
  21. if( abs(i)+abs(j)<=NUM)
  22.  
  23.  { cout<<"*"; }
  24.  
  25. else { cout<<" ";}
  26.  
  27. }
  28.  
  29. cout<<endl;
  30.  
  31. }
  32. return 0;
  33. }
Output:
*
***
*****
*******
*****
***
*

Tags:
About the Author

Write admin description here..

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

Related posts

0 comments:

ExactSeek Approved !!

Blogger templates. Proudly Powered by Blogger.
back to top