The code runs normal but only one output: Sunday ! regardless of the number chosen.
What the program should do
Implement a program that has a number ( 1-7 ) that corresponds to one of the days of the week and print the name of the corresponding day ( Sunday, Monday, Tuesday Wednesday, Thursday, Friday, Saturday ).
If the number read is not in the 1-7 range, print: Invalid day number .
The program must remain running until the user enters the number 0 . Please use a test at the beginning.
Code
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main(void){
char ch;
char domingo = '1',segunda = '2',terca = '3',quarta = '4', quinta = '5',sexta = '6',sabado = '7';
printf("digite um numero que corresponde a um dia da semana: n");
ch = getchar();
while(ch!= 0){
if (ch=1){
printf(" domingo n");
break;
}
else if (ch=2){
printf(" segunda n");
break;
}
else if (ch=3){
printf(" terca n");
break;
}
else if (ch=4){
printf(" quarta n");
break;
}
else if (ch=5){
printf(" quinta n");
break;
}
else if (ch=6){
printf(" sexta n");
break;
}
else if (ch=7){
printf(" sabado n");
break;
}
else if (ch>7 && ch!=0){
printf(" numero de dia nao valido n");
break;
}
}
}