After getting user input the program ends , what's wrong in this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

After getting user input the program ends , what's wrong in this code?

#include <stdio.h> int main(){     int month;     printf("Enter any number from 1 to 12 :");     scanf("%d",month);          switch(month){         case 1:             printf("%d Month is January",&month);             break;         case 2:         printf("%d Month is Feb",&month);         break;         case 3:         printf("%d Month is march",&month);         break;         case 4:         printf("%d month is apirl",&month);         break;         case 5:         printf("%d month is may",&month);         break;         case 6:         printf("%d month is june",&month);         break;         case 7:         printf ("%d month is july",&month);         case 8:             printf ("%d month is august",&month);             break;             case 9:             printf ("%d month is september",&month);         break;         case 10:         printf ("%d month is octomber",&month);         break;         case 11:             printf ("%d month is november",&month);         b

26th Dec 2018, 7:38 PM
Abdul Bari Abbasi
Abdul Bari Abbasi - avatar
4 Answers
+ 9
If this is your complete code which I guess isn't, then I don't see any mistake except for that you don't need to use ampersand/address operator in the printf statement. Just type variable name e.g: printf("%d month is Jan", month) ; It's better if you post a link to your code so we can see your complete code.
26th Dec 2018, 7:50 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 5
Paste your code here: https://code.sololearn.com/#c Save it Make it public Attach it here
26th Dec 2018, 7:46 PM
Babak
Babak - avatar
+ 3
You need ampersand in scanf. Put this: scanf("%d",&month);
26th Dec 2018, 10:15 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
0
nAutAxH AhmAd I'll post the link next.
27th Dec 2018, 7:42 AM
Abdul Bari Abbasi
Abdul Bari Abbasi - avatar