+ 1

Please help me in solving this cpp program[solved]

#include<iostream> class rev { int k,n,sum,p; public: void input(); void calc(); void display(); }; void rev::input() { cout<<"\nEnter any integer to find the reverse of it"; cin>>n; k=n; } void rev::calc() { sum=0; while(n>0) { p=n%10; sum=(sum*10)+p; n=n/10; } } void rev::display() { cout<<"\n\nThe no. you have entered is :"<<k; cout<<"\n\nThe reverse of the no. is :"<<sum; } int main() { rev o; o.input(); o.calc(); o.display(); }

12th Nov 2021, 3:06 AM
Samaan Sayed
4 Respostas
+ 3
You forget o include using namespace std; in your program cin cout .... These global objects belong to this library so it necessary to include that if u dont want write like this then u can do like this using std::cout , std::endl; Or you can write std when u using any of the object Like this std::cout<<" this is just for demo"<<std::endl;
12th Nov 2021, 6:55 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
https://code.sololearn.com/cI2MunRAfGuS/?ref=app U need to add "using namespace std" so that everything (cout & cin ) must be defined under this std .... And no need to add std with every cout and cin statement
12th Nov 2021, 3:44 AM
Pihu ( Not Active )
0
Pihu ( Not Active ) thanks, I forgot to put that
12th Nov 2021, 3:56 AM
Samaan Sayed
0
♨️A.S.♨️ thanks for helping me out
12th Nov 2021, 6:58 AM
Samaan Sayed