+ 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.]

24th Feb 2020, 11:37 AM
zahrad
zahrad - avatar
13 Answers
+ 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.
25th Feb 2020, 7:04 PM
Mihai Apostol
Mihai Apostol - avatar
+ 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.
24th Feb 2020, 11:39 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Oh my god.You wrote in Persian😊. Our language is very beautiful. I suggest you learn it.
25th Feb 2020, 7:21 PM
zahrad
zahrad - avatar
+ 1
zahrad It was just Google Translate. ماشاالله
25th Feb 2020, 7:27 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Just for a hint. ماشاالله is not a Persian word. It is an Arabic word. Its equivalent 'آفرین' is in Persian.
25th Feb 2020, 7:36 PM
zahrad
zahrad - avatar
+ 1
First take input and divide entered number by 100 ,1000 .... numbers will be seperate And store in different variables and print all variables
26th Feb 2020, 5:09 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
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?
25th Feb 2020, 6:43 PM
zahrad
zahrad - avatar
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;
25th Feb 2020, 6:51 PM
Mihai Apostol
Mihai Apostol - avatar
0
zahrad Is it ok like this? I can arrange the code a bit more if you like. Fox She finally gave it a try.
25th Feb 2020, 6:55 PM
Mihai Apostol
Mihai Apostol - avatar
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?😬
25th Feb 2020, 7:00 PM
zahrad
zahrad - avatar
0
Yessss.I really appreciate your help.Thank you very much(:
25th Feb 2020, 7:13 PM
zahrad
zahrad - avatar
0
zahrad You're welcome. خواهش میکنم
25th Feb 2020, 7:18 PM
Mihai Apostol
Mihai Apostol - avatar
0
Im having issue with understanding the if statement
26th Feb 2020, 9:06 AM
Folakemi Jane