Friday, 11 December 2015

Make A half diamond shap using loop in c++

#include<iostream>
#include <conio.h>
using namespace std;
int main()
{
  int n=5,c,k,space=1;  
   space=n-1;
  for(k=1;k<=n;k++)
  {
    for(c=1;c<=space;c++)
      cout<<" ";
     space--;
     for(c=1;c<=2*k-1;c++)
      cout<<"*";
     cout<<endl;
  } getch();
}

No comments:

Post a Comment