Suraj Bahadur

Suraj Bahadur
  • Home
  • Features
  • _Multi DropDown
  • __DropDown 1
  • __DropDown 2
  • __DropDown 3
  • _ShortCodes
  • _Sitemap
  • _Error Page
  • Seo Services
  • Documentation
  • Download This Template

How to print diamond pattern in c++ & c...

September 25, 2016 Programming Logic To Print Diamond Pattern In C and C++ .......n so on.
Following is the program to print diamond using for loop in any programming language.

#include<iostream>

using namespace std;

int main()

{

int row,c,k,space=1;

cout<<"enter number of rows that you want to see=";

cin>>row;

space=row-1;

for(k=1;k<=row;k++)

{ //for loop to print space

for(c=1;c<=space;c++)

{

cout<<" ";

}

space--; //decrement the number of spaces by 1 each time

//for loop to print stars

for(c=1;c<=2*k-1;c++)

{

cout<<"*";

}

cout<<"\n";//move to the next line

}

//following will print second half of diamond

space=1;

//here we need to increment the space from 1 2 3 4 and so on

for(k=1;k<=row-1;k++)

{

for(c=1;c<=space;c++)

{

cout<<" ";

}

space++;// increment the number of space by 1 each time

for(c=1;c<=2*(row-k)-1  ;c++)

{

cout<<"*";

}

cout<<"\n";

}

return 0;

}

Share This:
Facebook Twitter Google+ Pinterest Linkedin Whatsapp
Programming Logic To Print Diamond Pattern In C and C++ .......n so on.
at September 25, 2016
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Programming Logic To Print Diamond Pattern In C and C++ .......n so on.

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Popular

  • Way To Find  Serial Key Of Any Software Using Simple Newbie Trick
    Way To Find Serial Key Of Any Software Using Simple Newbie Trick
    Hi Newbie's ,  In this post i'm gonna give you a newbie tips and tricks to find any sofware serial key by using simple newbie tri...
  • [How to] Logic Behind To Print Pattern In Any language Using The Concept Of For Loop
    [How to] Logic Behind To Print Pattern In Any language Using The Concept Of For Loop
    Hi all newbie's , here in this tutorial i'm going to show a simple logic behind to print pattern using for  in any programming lang...
  • Part -2 :How To Print Diamond in C++
    #include using namespace std; int main(){ int i,j,k,row; row=3; for( k=1;k<=row;k++) { for(j=1;j<=3-k;j++){ cout<<...
  • How To Implement Chronometer In Android
    In this post i'll going to share the problem when implementing chronometer in android application Problem: I have one activity with t...
  • How to print diamond pattern in c++ & c...
    Following is the program to print diamond using for loop in any programming language. #include<iostream> using namespace std; ...

Tags

batch programming newbie tips and tricks Programming Logic To Print Diamond Pattern In C and C++ .......n so on. protect folder with password SHA1 Fingerprint cerification in android through Cmd Top 54 Hidden list of proxy sites trick

Search This Blog

Suraj Bahadur | 2016 |. Powered by Blogger.

Content

  • ▼  2016 (16)
    • ►  December (1)
    • ►  November (1)
    • ►  October (7)
    • ▼  September (7)
      • Create Launcher Icon For Android Application
      • Top 54 Hidden list of proxy sites
      • [HOW] to open banned websites with proxy
      • How to print diamond pattern in c++ & c...
      • How to print diamond pattern in c++ & c...
      • Google Sign In - How to obtain SHA1 fingerprint ce...
      • How To Make Android Web View Application With Spla...

Suraj Bahadur

Suraj Bahadur

Report Abuse

Follow @surajbahadur1

About Me

My photo
Suraj Bahadur
View my complete profile
Suraj D NeWbie | 

Linkedin

Suraj Bahadur

Instagram

Subscribe me

Posts
Atom
Posts
Comments
Atom
Comments

Visitors

suraj

  • Facebook
  • Twitter
  • LinkedIn
Created By SoraTemplates | Distributed By Blogger Templates