0
Can somebody help me. I was asked to create a program that reverse the number i enter using do while and a for loop
#include <iostream> using namespace std; int main() { long long int num,rem,rev=0; int count=0,temp; cout<<"Enter any number: "; cin>>num; temp=num; do { count++; temp/=10; } while(temp!=0); for (int i=1;i<=count;i++) { rem=num%10; rev=rev*10+rem; num/=10; cout<<rev; } return 0; }
1 Respuesta
+ 1
Bhavya Sarraf my prof wants a combination of do while and for loop is that possible?