Powered by Blogger.

Search

Saturday, 13 December 2014

Write a C++ program which inputs two integers from user and display the following sequence in the specified format Sample run: Enter starting integer: 1 Enter ending integer: 5 (1,1)(1,2)(1,3)(1,4)(1,5) (nextline) (2,2)(2,3)(2,4) (nextline) (3,3)




//This programme is tested on visual studio 2012//
#include <iostream>

using namespace std;

void main()

{

    int num1,num2;
    cout<<"------------------------------------------------------------------------------\n";
cout<<"This programme will print a pattern on entering starting and endind numbers \n";
cout<<"------------------------------------------------------------------------------\n";


    cout<<"Enter number 1 : ";

    cin>>num1;

    cout<<"Enter number 2 : ";

    cin>>num2;
cout<<endl;
    if(num1<num2)

    {

        for(int x=num1;x<=num2;x++)

        {

        for(int j=x;j<=num2;j++)

            {

            cout<<"("<<x<<","<<j<<")";

            }

        cout<<endl;

        num2--;

        }

    }
    else
    cout<<"Please enter first number less than second.\n";
cout<<"\n\n------------------------------------------------------------------------------\n";
    cout<<"Thank You for using.\n\nVisit http://bilalzahid22.blogspot.com/ for more\n";
  cout<<"\n------------------------------------------------------------------------------\n";

    }

Ditulis Oleh : Unknown // 02:26
Kategori:

0 comments:

Post a Comment

Translate