Write a C++ program that will print the pattern as shown below:
Output:
*
***
*****
*******
*********
*********
*******
*****
***
*

printf("*\n***\n*****\n*******\n*********\n*********\n*******\n*****\n***\n*");

I like it Moschops! Keep it simple...

commented: its not answer of my question +0

dear its not answer of my question

Do you know how to write an "Hello world." program in C++?
If yes, then just change the hello world in what Moschops wrote.
It is an answer to your question! Try it and see!

Since this is posted in the C++ forum how about:

std::cout << "*\n***\n*****\n*******\n*********\n*********\n*******\n*****\n***\n*";

Now we already have two perfectly legal answers!

Here is #3...

    std::cout << "*" << std::endl
              << "***" << std::endl
              << "*****" << std::endl
              << "*******" << std::endl
              << "*********" << std::endl
              << "*********" << std::endl
              << "*******" << std::endl
              << "*****" << std::endl
              << "***" << std::endl
              << "*" << std::endl;

Just pure C++ code!

it's code

//#include <iostream>
//using namespace std;

//main

int i , j;

int check = 0;
int ncout = 0;

for( i = 0 ; i<10 ; i++ ){

    if ( i > 5 ){
        ncout += 4 ;
    }else if( i == 5 ){
        ncout += 2 ;
    }

    check += (  i < 1 ) ? 1 : 2 ;

    for( j=0; j < check - ncout; j++ ){
        cout << "*";
    }

    cout << endl;

}

1222223.jpg

it's code @dbfud1988: first you should read the rules I guess, and second what do you think the other contributors posted other then code?

I do not know what your needs My code is written in accordance with your map

What do you mean by map?
Your code is quite OK that is not the point.

*
***
*****
*******
*********
*********
*******
*****
***
*
out put map

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.