How to write a code that asks for a persons gender and displays it? Am new to C btw. Is the code like this?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write a code that asks for a persons gender and displays it? Am new to C btw. Is the code like this??

{ Char gender; Printf("\nEnter M or F for your gender\n"); Scanf("%d",&gender); Printf( "your gender is %d",&gender); }

30th Apr 2019, 1:37 PM
Zabu
2 Answers
+ 8
If you are taking "char" as a data type you should use %c instead of %d. And well if you use char data type you will be able to store only one character. Hope you like that answer. If there is anything else, feel free to ask me.
30th Apr 2019, 2:03 PM
InfinityAJ
InfinityAJ - avatar
30th Apr 2019, 2:46 PM
raget88
raget88 - avatar