# Nested Loops Modulus

 Doctor Doctor · December 3, 2014 how can i create stars using c++ nested loops or modulus in this order 1-3-5-3-1thank you to whoever that can help me, i really appreciate it

## Replies

 Homer Simpson · December 3, 2014 ``#include #include int main(){    const int LOOP_SIZE = 10;    for(int i = 0; i < LOOP_SIZE; i++){        std::string stars(i, '*');        if(stars.size() % 3 == 0){            std::cout << stars << std::endl;        } else if (stars.size() % 5 == 0){            std::cout << stars << std::endl;        }    }}``I don't really understand your question. How exactly do you want to display the stars? Everything modulus 1 = 0 so that would just print out 1 star then 2..3..4 so on. Anywho, this code prints this.*********************** Stan Botha · December 22, 2014 ``#include using namespace std;void displayRow(int n){for (int i = 1; i <= n; i++)cout << '*';cout << endl;}int main( ){int m = 10;for (int j = 1; j <= m; j++)     {          if(j<=(m/2) && j%2!=0)               displayRow(j);          else if (j>(m/2+1) && j%2!=0)               {                    displayRow(m-j);               }     }return 0;}`` Doctor Doctor · December 31, 2014 #include  using namespace std; int main() { int a , b ; int operation ; cout<<" enter two numbers : " << endl ; cin>> a ; cin>> b ; cout<<"what the operation do you want :" <> operation ; switch(operation){ case 1 : cout<<"a+b = " << a+b; break; case 2 : cout<<"a-b = " << a-b; break; default: cout<<" " <
• 1

## C++

123,017 followers