So, my college professor gave us a list of programmes we should write, and he asked us, for some reason I dare not ask, to bring it out in paper, as in written off with a pencil - yeah, he is an arsehole.
Well, I thought I had it all planned. I wrote the programmes and left them on my laptop, so that I could write them down today.
Then I got to the fourth question and realised there was a mistake.
Take a look at the programme I wrote:
#include <stdio.h>
#include <stdlib.h>
int main () {
int age;
char sex, name [100];
printf ("Type in your sex, 'M' or 'F': ");
scanf ("%c",&sex);
printf ("Type in your age: ");
scanf ("%d",&age);
printf ("Type in your name: ");
scanf ("%s",name);
if ((sex=='F'||'f')&&age<25){
printf ("%s accepted\n",name);
}else{
printf ("%s not accepted\n",name);
}
system ("pause");
return 0;
}
See, the programme should read your name, your sex, and your age and print "(name) accepted" in case you are a female under the age of 25, or, if you are not al those things, "(name) not accepted".
The thing is, the way I wrote it, everytime a type "m", or "M", in the sex part, and then input an age lower the 25, it prints "(name) accepted", when it should not!
I have absolutely no idea what I did wrong, but I need your help correcting it.
Please, use those functions I used, I have just started out the course.
Thank you very much just for reading this - it got a little long, I tend to write a lot, sorry
I'm sorry, can you explain it better? I was just staring at the screen but I couldn't understand what you tried to tell me!
And sorry I didn't use the code tag...
Nevermind my question, I found out what I was doing wrong later, and just finished copying all 10 questions - yes, he is that big an arsehole -, but I appreciate ne555's kind answer.
Thank you guys \o