How can u take input in int and covert into string | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How can u take input in int and covert into string

Example User input =1 Output =One I am getting a lot of errors plz help me https://code.sololearn.com/c46fMWEb7WqF/?ref=app

16th May 2021, 3:45 AM
Vishal Rathod
Vishal Rathod - avatar
4 Respuestas
+ 3
This code coach intends for you to use a loop to take the input 3 times. Then use a switch to check for the numbers 0-10 inclusive. You can set a string value to the corresponding number word ("Zero", "One", "Two", etc). Then output the correct number word for each input.
16th May 2021, 3:59 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Vishal Rathod you can loop over the switch 3 times also and take input inside the loop
16th May 2021, 5:59 AM
Atul [Inactive]
16th May 2021, 5:43 AM
Vishal Rathod
Vishal Rathod - avatar
0
Vishal Rathod Hint- Make a function with parameter and write switch case there and call that function 3 times with different parameter like this: func convertToWord(num int) { switch { num == 1: fmt.Println("One"); num == 2: fmt.Println("Two"); ....... ......... And so on. } } Call this function 3 times in main function after taking user input like this: func main() { convertToWord(a); convertToWord(b); convertToWord(c); }
16th May 2021, 5:01 AM
A͢J
A͢J - avatar