There is a mistake in this code .i couldn't find it .please help me . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

There is a mistake in this code .i couldn't find it .please help me .

C programming https://code.sololearn.com/cJaY5AVpTeI0/?ref=app

25th Dec 2019, 4:16 PM
Deshani Malawana.
Deshani Malawana. - avatar
5 Answers
+ 3
Please review the lesson, seems you're still unsure which type is appropriate for a purpose. You use `int` for asking a person's name when you should be using `char` array.
25th Dec 2019, 4:46 PM
Ipang
+ 2
Don't use gets() Instead, try like this: scanf("%d", &name);
25th Dec 2019, 4:26 PM
Tibor Santa
Tibor Santa - avatar
+ 2
Okay thank u
25th Dec 2019, 4:33 PM
Deshani Malawana.
Deshani Malawana. - avatar
+ 2
Deshani Malawana. If you are taking a single string input then it is recommended to use scanf() and never ever use gets(). Next if you are taking a character array as input then I don't think that you can pass it to switch(). Also the cases inside switch() are integer values which is not compatible to the type you are passing to it. Edit: int name; Why is name an integer type? You are confused and have not understood variable type declaration.
25th Dec 2019, 4:41 PM
Avinesh
Avinesh - avatar
+ 2
Thank you for your early response
25th Dec 2019, 5:01 PM
Deshani Malawana.
Deshani Malawana. - avatar