# 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.*********************** 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<<" " <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;}`` Franz Schmidt · December 31, 2014 Your code just has one function (the main function) and you just need to split the main in some partfunction which you combine in the main.So you mean something like this or something else?https://paste.ab-storm.de/view/d1065372034bf1b270535fb35adb2d13Hope you are familiar with functions and struct.Hope you understand everything. If there are any questions, just ask
• 1

## C++

123,259 followers