hi i m new 2 the whole C++ n i think its lods of fun i'vebeen puttin a program 2gether...but 4 some reason it always seems 2 crash when askin 4 the person status( married etc..)
the program has been written in french....but i doubt any1 is interested in wat is written with scanf
i would like 2 thank u all in advance 4 ur time n help
Code:
#include <stdio.h>
int main(void)
{
int nblivre, c;
float kg, cels, frnht;
printf("Taper le poids en livres:\n");
scanf("%d", &nblivre);
printf("Taper la temperture en degres farenheit:\n");
scanf("%f", &frnht);
cels = ((frnht - 32) / 9) * 5;
kg = 0.454 * nblivre;
printf("\nLe patient pese %.1f kg, a une temperature de %.1f degres", kg, cels);
fflush(stdin);
getchar();
printf("Selectionnez votre status civile:");
fflush(stdin);
getchar();
printf("\n\nAffichage avec switch (suivant que) :\n");
switch (c)
{
case 'c':
printf("celibataire.");
break;
case 'C':
printf("celibataire.");
break;
case 'a':
printf("un autre cas.");
break;
case 'A':
printf("un autre cas.");
break;
case 'm':
printf("marie.");
break;
case 'M':
printf("marie.");
break;
case 'd':
printf("divorce.");
break;
case 'D':
printf("divorce.");
break;
printf("\n");
fflush(stdin);
getchar();
return 0;
}
}
believe my problem is located around the switch level, n i dont know how 2 use it 2 well, that is IF i used it well....tks 4 every1;s help
with the c>>> As far as I can tell, the variable c is never assigned a value. That may or may not be your problem.
how do i set it up as a value 4 letters...do i use char?
ty all for ur time n help