+ 1
A questin of c++
Can anyone help me with this question? 👇👇 Write a program that inputs a five-digit integer, separates the integer into its digits and prints them separated by three spaces each. [Hint: Use the integer division and modulus operators.]
13 Respostas
+ 1
zahrad Yes ok. Replace in the line I gave you the \n with three spaces. Like this.
cout <<"result: "<<e<<" "<<d<<" "<<c<<" "<<b<<" "<<a;
Edit: I didn't read completely your first description with the three spaces.
+ 3
Thanks for the hint. Useful...
But for you. First you have to give it a try and if you face problems, people here will be happy to help you.
+ 1
Oh my god.You wrote in Persian😊.
Our language is very beautiful.
I suggest you learn it.
+ 1
zahrad It was just Google Translate.
ماشاالله
+ 1
Just for a hint. ماشاالله is not a Persian word. It is an Arabic word. Its equivalent 'آفرین' is in Persian.
+ 1
First take input and divide entered number by 100 ,1000 .... numbers will be seperate And store in different variables and print all variables
0
#include <iostream>
using namespace std;
int main()
{
int A;
int a;
int b;
int c;
int d;
int e;
cout <<"Enter a five-digit number:";
cin >>A;
a=A%10;
b=(A/10)%10;
c=(A/100)%10;
d=(A/1000)%10;
e=(A/10000)%10;
cout <<"result:"<<e<<d<<c<<b<<a;
return 0;
}
Can you edit my code?
0
zahrad
You did very good.
Results are ok.
Only output needed some tweaking, like this:
cout <<"result:\n"<<e<<"\n"<<d<<"\n"<<c<<"\n"<<b<<"\n"<<a;
0
Thanks for your help. But I want the numbers to be printed in tandem with 3 spaces.
Like this:4 3 6 1 9
Can you help me?😬
0
Yessss.I really appreciate your help.Thank you very much(:
0
zahrad
You're welcome.
خواهش میکنم
0
Im having issue with understanding the if statement