Answer to Question #21573 in C++ for saad

Question #21573
Write a program that reads 5 numbers from the user and print the output according to following pattern

12345
23451
34512
45123
51234
1
Expert's answer
2013-01-14T10:53:13-0500
#include <iostream>

using namespace std;

int main()
{
cout << "please enter 5 numbers" << endl;
int a[5];
& &
for(int i=0;i<5;i++)
{
& cin>>a[i];
& b[i]=a[i];
}
& cout<<endl<<endl;


//////// 1
cout<<a[0]<<a[1]<<a[2]<<a[3]<<a[4];
cout<<endl<<endl;
//////// 2
cout<<a[1]<<a[2]<<a[3]<<a[4]<<a[0];
cout<<endl<<endl;
//////// 3
cout<<a[2]<<a[3]<<a[4]<<a[0]<<a[1];
cout<<endl<<endl;
//////// 4
cout<<a[3]<<a[4]<<a[0]<<a[1]<<a[2];
cout<<endl<<endl;
//////// 5
cout<<a[4]<<a[0]<<a[1]<<a[2]<<a[3];
cout<<endl<<endl;


return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
08.12.15, 09:29

Dear Drishti Questions in this section are answered for free. We work on all questions and publish answers after verification. There is no guarantee of answering certain question but we are doing our best. Although if you have serious assignment that requires large amount of work and hence cannot be done for

Drishti
07.12.15, 12:53

12345 23451 34512 45123 51234 I need this pattern in C. please help me write the code for this pattern. x

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS