Pages

Saturday, March 29, 2025

Inverted Star Patterns problem in C++

 #include <iostream>

#include <cmath>
using namespace std;
// inverted star pattern problem in C++

int main() {
    int n = 4;
   
    //outer loop
    for(int i=1; i <= n; i++){
        // inner loop
        for(int j = 1; j <= n-i+1; j++){
            // work
            cout << "* ";
        }
        cout << endl;
    }

    return 0;
}

OUTPUT-
* * * * * * * * * *

No comments:

Post a Comment

Stack using Linked List – Partial (University Exam Topic)

 #include <iostream> using namespace std; struct Node {     int data;     Node* next; }; class Stack {     Node* top; public:     Stac...