Nov 22, 2017 Awais Liaqat

Draw Number Pattern Using Nested For Loop C++
4   0   34   Programming - C++

Facebook   Twitter   Google   Email
post-img
 

Introduction

Draw a pattern using nested for loop in c++ that print numbers in output. here is the code for solutions


Source Code:

#include<iostream>
using namespace std;

int main(){
    int k;
    for(int a = 5; a > 0; a--)
    {
        k = 1;
        for (int b = 1; b <= a; b++)
        {
            cout<<k;
            k = k + 2;
        }
        cout<<endl;
        k=1;
        for (int b = 1; b <= a; b++)
        {
            cout<<k;
            k = k + 2;
        }
        cout<<endl;
    }
}

Output:

1 3 5 7 9
1 3 5 7 9
1 3 5 7
1 3 5 7
1 3 5
1 3 5
1 3
1
1

Is this helpful?   Yes   No

Facebook   Twitter   Google   Email
Click to copy
Successfully copy the link to share

Leave a Comment


Comments (0)


Thank you for your feedback
You are now following
Request Sent! Wait for Approval
Removed From Following
Something wents wrong!
Thank you for your comment