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

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!

Edited 1 Year Ago by ddanbe: corection

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

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

Edited 1 Year Ago by NathanOliver

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!

Edited 1 Year Ago by rubberman

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?

Edited 1 Year Ago by ddanbe: correction

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

Edited 1 Year Ago by dbfud1988

This article has been dead for over six months. Start a new discussion instead.