C Programming Tutorial - 18 - Nesting if Statements

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Dude, you are a life saver!

I've spent 6 hours on this assignment, and most of the time has been trying to get this stupid nested if statement to work! THANK YOU!

Samcanplaymusic
Автор

"Some Users might press F", unintended meme

willmcconnell
Автор

For those who had a problem with %c and %s, cos it certainly fucked my program until I realised he had put that instead - here is something taken from yahoo answers:

the input or output of a single character and has to be used with char datatype
the input or output of a set of character(String) and has to used with a character array

ScantaniouslyCombust
Автор

// (') Single quotation marks is for single character
// (") Double quotation marks is for string

[ In C programming ]

victormilan
Автор

Very helpful tutorial ! Before this I never knew that leaving a space in the scanf parentheses would make a difference.

rockstorm
Автор

It should be "m/f/ah" for Attack Helicopter :)

CatholicismRules
Автор

Thank you. I'm teaching myself from a SAMS guide for beginners book and this bug if the compiler has had me pickled for an hour!!!

michaelgannon
Автор

you know what I do sometimes? I use the YouTube control to speed him up x1.5... it`s so wonderful.. it`s like I am flying... this is too good... thank you bucky, thank you .

HikikomoriDev
Автор

this makes more sense

#include<stdio.h>
int main()
{
int age;
char gender;
printf("how old are you\n");

scanf(" %d", &age);

if(age>=18)
{
printf("what is your gender?(m/f)\n");
scanf(" %c", &gender);
}


if(gender=='m'){

printf("welcome to the website sir\n");

}

if(gender=='f' ){

printf("welcome to the website mam\n");

}

if(age<18){

printf("your not allowed to view this content");
}

}

amaypagrut
Автор

For those whose answer is printing dude and m' lady at the same time, you kept a semicolon at the end of IF statement

Crazyboy-tzct
Автор

i'm here now guys! this code is quite catchy

jamesbrown-yrcz
Автор

Thanks Alot...much helped since tutorial 1 Sir..

esstalai
Автор

Putting a space before %d or%s will clear the console buffer. It is shortcut to do that. Otherwise you have to do it manually like this :

 #include <stdio.h>
#include <stdlib.h>

int main()
{


int age;
char ch;
char gender;

printf("what is your age?\n");
scanf("%d", &age);
while(ch=getchar()!='\n');// this is the concept of buffer / console clearance.

printf("my age is : %d\n", age);
printf("what is your gender?\n");
scanf("%c", &gender);

if (age>=18){
    printf("your welcome ");
  if (gender=='m')
    printf("dude");
else printf("my Lady");
}
 else printf("Bye Bye..!!");
}

anshulvyas
Автор

bucky man you are awesome you are doing great job!!1

ajay
Автор

now i understand if there is only 1 character so we use %c, =))

jamesbrown-yrcz
Автор

u are the best man thanx u soo much just continue ...

abbadkamel
Автор

The leading space before the modifier %c informs scanf() to skip leading whitespace characters, tabs and newline characters

hossamsamir
Автор

Why does "%c"(without space) make bug? (Why should we use " %c"(with space)?)
We've already used "%d"(without space) many times and I've never seen errors about them.

seong
Автор

Thank you for all the info!  
Are there gum chewing I hear in this??  

rrupp
Автор

1:10 some people might just press F


I respect that joke

thephysicistcuber