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
#include using namespace std; int main() { int number=0; do { & number++; & if(( number
sir kindly help me to this question c++ program to print all the palindrome between 1 and 100 using do while do
Leave a comment