After getting user input the program ends , what's wrong in this code? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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