Got your problem!
Never use newlines, whitespace, tabs and return carriages inside scanf as to avoid such problems and maintaining good coding guidelines! These act as delimiters for it and you have provided 3 of them.
Edit your menu scanf to this:-
scanf("%d",&k);
A basic logic behind it:- Taking a basic example :-
scanf("%d %d", &i, &j);
Notice that space between two placeholders. When you run this, it will take the first input and then it will wait for that delimiter to be read from the keyboard and afterwards it will read the second parameter of the input.
I think the rest of the program should run fine.
1
solved Error While taking the input