+ 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(); }
4 Answers
+ 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;
+ 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
0
Pihu ( Not Active ) thanks, I forgot to put that
0
â¨ď¸A.S.â¨ď¸ thanks for helping me out