0

why this c code is'nt runnin ?

include<stdio.h> int main() { int day,A,B; printf("enter day\n"); scanf("%d",&day); switch(day) { case 1: printf("Monaday"); break; case 2: printf("Tuesday"); break; case 3: printf("Wednesday"); break; case 4: printf("Thursday"); break; case 5: printf("Friday"); break; case 6: printf("Saturdat"); break; default: printf("sunday"); } return 0; }

6th Mar 2023, 11:11 AM
Aditya Kumar Tonk
Aditya Kumar Tonk - avatar
8 Réponses
+ 3
It runs but print gives you warning. May be wrong output. Remove A, B. Monday, Saturday spellings are wrong in English. If it is other language, may be correct
6th Mar 2023, 8:53 PM
Jayakrishna 🇮🇳
+ 2
You are missing a '#' before 'include' #include <stdio.h>
6th Mar 2023, 1:05 PM
XXX
XXX - avatar
+ 2
Next time when you ask for help, please be sure to state the exact error that you are getting as well as tag the relevant programming language.
6th Mar 2023, 1:40 PM
Justice
Justice - avatar
+ 1
Aditya Tonk Uk07 It runs fine after that. Maybe you're having problem with giving input? You have to give the input in the pop-up box that comes up when you run the code. Note that your program does give 2 warnings, but they are only warnings for unused variables. They are NOT errors. If this is a code coach problem, or some code problem on another website, then you need to fix the spellings of the days in order for the tests to pass. So apart from the missing '#', the code does run
7th Mar 2023, 2:53 AM
XXX
XXX - avatar
0
bro # isjust not copied i surely write it on my code but still i doesn't run
6th Mar 2023, 2:03 PM
Aditya Kumar Tonk
Aditya Kumar Tonk - avatar
0
Try to add # in your header file & check properly your code next time
7th Mar 2023, 8:03 AM
Sunil Choudhary
Sunil Choudhary - avatar
0
ise dosenot use header tag. That means you should use #include<stdio.h>
7th Mar 2023, 11:00 PM
Abdun Nur Porag
Abdun Nur Porag - avatar
0
things gone wrong: (1) including libraries you can't use printf( ) for output and scanf() for keyboard input until you include the standard library for input/output, which is stdio.h you tried to include it , but the right sintax is #include <stdio.h> you missed the "#" so you are unable to use prinf() and scanf() until you add it (2) declarations C, as C++ is pretty good for shrinking memory usage, so compilers are made to alert you when you're wasting memory and/or resouces in general, as when you define and declare a variable that is not used in code in this case you have declared two int, reserving memory for them, in the varables named "A" and "B", with the syntax int day,A,B; BUT you don't use any of them in your code, so compiler - assuming you may want to implemenet them later - gives you a WARNING: "in row 5 of your code, inside the main function, you declared A and B and I reserved memory to store them, but it's waste of memory as you never use them, you little memory_wasting_addict" that is the meaning of "./Playground/file0.c: In function 'main': ./Playground/file0.c:5:15: warning: unused variable 'B' [-Wunused-variable] 5 | int day,A,B;" so, if not needed for future use/future code remove line 5 int day,A,B; and use instead int day; and all will work fine :) the resulting code: #include <stdio.h> int main() { int day; printf("enter day\n"); scanf("%d",&day); switch(day) { case 1: printf("Monaday"); break; case 2: printf("Tuesday"); break; case 3: printf("Wednesday"); break; case 4: printf("Thursday"); break; case 5: printf("Friday"); break; case 6: printf("Saturdat"); break; default: printf("sunday"); } return 0; } (3) not pertaining code but mistypo: in case 1, line 9, you use string "Monaday" perhaps you want to output "Monday" :) happy coding!
8th Mar 2023, 10:19 AM
Gianluca Deidda
Gianluca Deidda - avatar