Question #5560

write a c++ programme to print any 10 no given in array in reverse order

Expert's answer

#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

{

& cin>>s; //read one integer

& 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;

}

#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

{

& cin>>s; //read one integer

& 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;

}

## Comments

Assignment Expert15.12.11, 16:34#include <iostream>

using namespace std;

int main()

{

int number=0;

do

{

& number++;

& if(( number<10)||(number%10==number/10)) cout<<number<<endl;

} while (number!=100);

}

Jimmy15.12.11, 08:59sir kindly help me to this question

c++ program to print all the palindrome between 1 and 100 using do while do

## Leave a comment