Who can solve this problem? Enter N: 5 10 8 6 4 2 10 8 6 4 10 8 6 10 8 10

Nested Loop

HOME Forums Forum Nested Loop

This topic contains 2 replies, has 2 voices, and was last updated by  Orn Chhai lim 1 year, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #901 Reply

    Online Training
    Keymaster

    Who can solve this problem?

    Enter N: 5

    10 8 6 4 2
    10 8 6 4
    10 8 6
    10 8
    10

    #902 Reply

    Chheang Sopheaktra
    #include<iostream.h>
    #include<conio.h>
    void main()
    {
    	int n;
       cout<<"Input N=	";	cin>>n;
       for(int i=1;i<=n;i++)
       {
       	for(int j=n;j>=i;j--)
          {
          	cout<<j*2<<" ";
          }
             cout<<endl;
       	}
       getch();
    }
    
    #903 Reply

    Orn Chhai lim

    #include<iostream.h>
    #include<conio.h>
    void main()
    {
    int n;
    cout<<“Enter N: “;cin>>n;
    for( int i=1;i<=n;i++){
    for( int j=n;j>=i;j–)
    cout<<” “<<j*2;
    cout<<endl;
    }
    getch();
    }

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Nested Loop
Your information: