107 309
Assignments Done
98.9%
Successfully Done
In March 2023

# Answer to Question #5560 in C++ for Jimmy

Question #5560
write a c++ programme to print any 10 no given in array in reverse order
1
2011-12-08T12:38:40-0500
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int st(int s) //function that raises 10 to a power
{ //of s which is an argument
int val=1;
for (int i=0; i<s; i++)val*=10;
return val;
}

int main(int argc, char *argv[])
{
int array[10]; //array to input
string s; //string for reading one integer form the line
int i,j,length; //counters and a variable for string length
for (i=0; i<10; i++)array[i]=0; & //fill the array with nulls
cout<<"Enter 10 integers separated by spaces"<<endl;
for (i=0; i<=9; i++) //cycle for filling the array with 10 integers
{
& length=s.length(); & //count its length
& for (j=0; j<length; j++) & //take one digit from integer
& {
array[i]+=int(s[j]-'0')*st(length-1-j); //convert it from char to int,
& } //multiple it to the proper power of 10 and save in array
}
for (i=9; i>=0; i--)cout<<array[i]<<' '; //output the array in reverse order
system("PAUSE");
return EXIT_SUCCESS;
}

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!

Assignment Expert
15.12.11, 16:34

#include using namespace std; int main() { int number=0; do { & number++; & if(( number

Jimmy
15.12.11, 08:59

sir kindly help me to this question c++ program to print all the palindrome between 1 and 100 using do while do