C Programming Tutorial – 22 – or

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Comments

KingZuluKing says:

Bucky, i love you bro ! thanks god still exist people like you man. Keep up the good work, Greetings from Berlin

Jon Ang says:

if i were to input “yn” i would still get it right, how do i prevent that?

Deelaw CS GO says:

#include
#include

int main()
{
int favorite ;
printf(“If you like COD or Java then you are my best friendn”);
scanf(” %d” , &favorite);

if ((favorite == ‘COD’) || (favorite == ‘Java’)){
printf(“You are my best friend”);
}else{
printf(“We are enemies”);
}
return 0 ;
}

This code never runs the “printf(“You are my best friend”); ” if the answer is COD or Java it skips that and prints We are enemies

asdiofjasdf says:

Hm, having a struggle. I dont know the difference between arrays and variables. Makes it difficult to know when to put &.

Osi famosi says:

Im not from the Us and i see lots of comments like “Your videos help me a lot at school”. My question is: is coding a common subject in the Us?

agenten says:

Hi these videos are amazing but I wonder if you could zoom in your text quite a bit because it’s very hard to sit back and watch on my small 1080p monitor.

Ani Pathak says:

great way to learn…

ying tang says:

I write this code. When I put 71, it says “Bad choice.”, but when I put 7.9, it says”You make the right choice”. Why?

#include
#include

int main()
{
int number;
printf(“What is your favorite number? n”);
scanf(” %d”, &number);

if(number==7 || number==1){
printf (“nYou make the right choice.n”);
}else{
printf(“Bad choice.n”);
}
return 0;
}

I React to Everything ! says:

Please….. What software are using ???

Logan Graham says:

how do you make the program do or in a way that it it wont trigger if both are try
like?

if ( (test1) || (test1)){
if ((test1) && (test2)){
}else{
\do some code here
}
}

just seems like a lot of code to me is all

bhuranuddin dhariwala says:

and it is nly making people to leave this tuts and went to other  . . . 

shivam dev says:

if i use true/false instead of y/n then how to deal with this?
eg. 
     char answer;

   printf(“Hexagonal have 6 side ?  (True/False) n”);
       scanf(” %s”, &answer);

    (answer == ‘true’ ) ? printf(“Right!”) : printf(“Wrong!”);
 every time i am getting answer “Wrong” why? please help

Karanvir Sandhu says:

#include
#include

int main()
{
char decision;

printf(“Do you love coding? n”);
scanf(“%c”,&decision);

if((decision==’y’)||(decision==’n’)) {printf(“You’re awesome ! n”);}
else {printf(“You should watch more Bucky’s videos and you will love it ! n”);
}

return 0;
}

atna mas says:

Bucky is such an inspiration !

Karanvir Sandhu says:

I am falling in love with programming since i started watching your videos !
-An aspiring programmer

and love for bagels !

Djamel Arab says:

hello guy’s , it doesn’t work with me this time when i use the “or” symbol “||” !! any one can help??!
and the problem is when i change it from characters to integer it works !!!!!!!!

shizyninjarocks says:

Meatball

Milli Millz says:

Bucky you are a life saver!!!!!!!! Thanks bro.
– A college student

ZeSuGaming - Fortnite says:

I know this is stupid and simple compared to your guys’ stuff but I’m proud of it:

#include
#include

int main()
{
char answer;
printf(“Do you have school tomorrow? y/n n”);
scanf(” %c”, &answer);

if( (answer==’y’) || (answer==’n’) ){
printf(“Didn’t ask you. Shut it. n”);
}
int scale;
printf(“On a scale of 1-10, how mad are you right now? n”);
scanf(” %d”, &scale);

if(scale > 5){
printf(“ur mad lel n”);
}
if(scale < 5){ printf(“Get mad then! n”); } printf(“Goodbye.”); return 0; }

Nathan Coates says:

your so awesome

Mike M says:

make sure to use single quotes instead of double quotes when checking a statement. Single quotes are used for chars and double for strings.

Zackbare says:

Zero dislikes!!

Engku Fizz says:

erm.. why did you use %c instead of %s for string? and why we use single quotation instead of double quotation for y and n? is it because of y and n are not a string? if it is not a string then what it is?

vljzlj says:

It is gonna be displayed as “good job” even if they type ” yes” instead of just “y” because it stars with a “y” or “n”. :)

Gobberfisch says:

What about xor? C must have something like this, am I right?

chorrdus De_fat says:

yesss dat one dislike is meee ye mee lol

Sunghoon Nam says:

0 dislike here… awesome!!

Irad Tn says:

Thanks a lot for those videos . i’m starting to study electrical engineering in Berlin and i watched all your videos to help me to get ready for my studies .

Ducktales says:

cant you print more else if statements? or am I stupid?

bhuranuddin dhariwala says:

y u r not increasing the size of fonts …coz it become too difficult to read what u r tying even on 1080 px quality  . . . 

Mo's TV says:

Can any body help me here .
I actually try running this code, but I keep getting error with in the if state that I don’t understand, the program is about asking user for their login name and afterward make sure that they provide the required name, using the if statement. 

#include
#include

int main(){
   
           char name[10];      // jubril, darame
  
    
    printf(“Enter Login namen”);
    scanf(” %s”,  name);
    printf(“welcome %s”, name);
    
    if (name == “jubril”) {
        printf(“you welcome sire “);       
    }
    else{
        printf(“sorry u are not autorized here”);
    } 
    }return 0;

Screen Shot 2015-05-01 at 10.41.22 PM.png

taqiy muhammad says:

Thanks a lot for these videos, your really good at explaining this c programming!!! helped out a lot in my class CMIS 102… Keep it going man!!

Swapnil G. says:

thanks!

search info says:

First video on youtube with this many views/likes and zero dislikes!……… I think I shall make this sacrifice……

keshav tangri says:

in java for comparing string we use .equalsto() function …. do we use it here also ????

guoitdreuy says:

Hey I know this is just a simple example to show the OR test but I ran the program and entered yn and the program returned ‘good job you didn’t mess anything up’ How would you structure it so that it can ONLY be y or and not both? Cheers

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours