Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

make an x using asterisk c++

//This is one that will involve user input to create an "X" using
//Asterisks.

#include <iostream>
using namespace std;
int main() {
  int size;
  
  cout << "This is where you ask for size: ";
  cin >> size;
  
  for(int i = 1;i <= size; i++) {
    for(int j = 1; j<= size; j++) {
      if((i == j) || (j == (size + 1) - i)) {
        cout << "*";
      } else {   
        cout << " ";
      }
    }
    cout<< endl;
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #asterisk
ADD COMMENT
Topic
Name
5+3 =