Тёмный
No video :(

C Programming Tutorial - 23 - Shorthand if else 

thenewboston
Подписаться 2,7 млн
Просмотров 178 тыс.
50% 1

Source Code: github.com/the...
Core Deployment Guide (AWS): docs.google.co...

Опубликовано:

 

20 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 136   
@alexshepler403
@alexshepler403 6 лет назад
I like how you went through your phases on your videos. first photo editing, then computer build, now to video editing, then to video games, then to coding
@muhammadrafay4743
@muhammadrafay4743 5 лет назад
One of the best teacher of programming I have ever seen you have made my programming way better than I thought.
@SUNNySINGh-if6jd
@SUNNySINGh-if6jd 5 лет назад
This is 2019 and hell this tutorial is better than any tutorials uploaded nowadays damnn...........
@seanbrown1863
@seanbrown1863 10 лет назад
Hey Bucky, I love you
@EllixV
@EllixV 8 лет назад
your teaching/ explanation has gotten better in this video
@yukiyoshida1226
@yukiyoshida1226 3 года назад
Omg!!!!!!!!! You are amazing bucky!!!!! I just want to say truckload of thank you!!!!! I am so so sooo much thankful for your videos...I am getting better and better because of your tutorials ...cause before watching your lectures, I was soo much bad in programming( seriously, my teacher don't know how to teach)....but now I am getting more and more better at programming❤ ....Thank You soo much❤❤
@sravyapullagura
@sravyapullagura 10 лет назад
a really good example for demonstrating the ternary operator..thanks a lot bucky
@DanielGuzman31
@DanielGuzman31 9 лет назад
I'm taking C programming in college and I really didn't have a background in programming! My professor is awesome but has a heavy accent! Plus he goes so freaking fast!! Your tutorials are helping me so freaking much!! Thanks for taking your time to teach us! ;) now I feel way more comfortable in coding ;)
@emregumus6152
@emregumus6152 2 года назад
did you end up being a coder? I'm in the same situation cant learn from my prof so watching his videos to catch up..
@DanielGuzman31
@DanielGuzman31 2 года назад
@@emregumus6152 yes, I’m a software engineer now and I graduated with a B.S in Computer Information Technology. There were times when I though I just couldn’t do it, but you just have to work hard and give your very best, and not give up! Study and practice and practice a lot! And eventually you will learn to code ! You got this bro!
@emregumus6152
@emregumus6152 2 года назад
@@DanielGuzman31 thank you man I appreciate your reply. I just started a month ago and struggling but im studying at least 8 hours a day let us see if I can manage it like you.
@DanielGuzman31
@DanielGuzman31 2 года назад
@@emregumus6152 you got this! It takes time, lots of practice and lots of patience! Also C, C++ aren’t just the only programming languages out there, there’s better languages and easier languages to learn like Python, JS, Java and others :) so much to learn in this career ! Keep it up !
@bigmacdoubleyouv
@bigmacdoubleyouv 8 лет назад
I always wondered what the ? : meant in code. Thanks. Love your videos.
@jamesbrown-yr5cz
@jamesbrown-yr5cz 9 лет назад
i'm here now!! lesson 23!!
@mehmetsahin7313
@mehmetsahin7313 6 лет назад
what about now bro ?
@SUNNySINGh-if6jd
@SUNNySINGh-if6jd 5 лет назад
@@mehmetsahin7313 what about now
@mysticlunala8020
@mysticlunala8020 4 года назад
NOW?? XDDD Bucky da best!
@53756e647176697374
@53756e647176697374 9 лет назад
Shtring
@gideonayodotun4825
@gideonayodotun4825 4 года назад
Thanks to you Bucky, you made this video so easy as reading alphabets
@SaintJimmyGun
@SaintJimmyGun Год назад
Thank you for being awesome! Really helps my learning process 😎
@user-ei2zq9rp5j
@user-ei2zq9rp5j 6 лет назад
Happy Christmas with goddamn great lecture!
@3PercentOcean
@3PercentOcean 2 года назад
sir, your videos are really awesome!
@leo-rq2ei
@leo-rq2ei 8 лет назад
love ur videos
@yerrapotukiran9400
@yerrapotukiran9400 7 лет назад
Thank you Bucky
@alonzathompson2104
@alonzathompson2104 8 лет назад
Thanks for the vids...really appreciate this
@huskie5279
@huskie5279 9 лет назад
Thanks Bucky :) God bless you!
@nicudrosu4314
@nicudrosu4314 8 лет назад
This is amazing, thank you so much for these.
@MathematicsOptimization
@MathematicsOptimization 8 лет назад
6:41 why did the "friend" term turned blue? Is friend a valid statement in c?? ))
@alexshepler403
@alexshepler403 6 лет назад
it is a function type. it is used in C++
@kaizen1720
@kaizen1720 8 лет назад
Brilliant, these are so useful.
@rohit_veer588
@rohit_veer588 8 лет назад
Bucky you re awesome Bro I have Use Two Shorthand if else in a single Printf statement and Made this #include #include int main(){ int friends; char name[6]; printf("What is Your Name? "); scanf(" %s", name); printf("How Many Friends Do you Have? "); scanf(" %d", &friends); printf("%s has %s %d Friend%s ", name, ((friends!=1) ? "" : "Only"),friends, ((friends!=1) ? "s" : "")); return 0; }
@rajghosh95
@rajghosh95 8 лет назад
did the same too :)
@starmediastarmedia6238
@starmediastarmedia6238 7 лет назад
awesome
@amandeep01010
@amandeep01010 4 года назад
This can be most helpful while printing an array with elements separated by comma. You always end up with last element appended by comma. Here is the code of what am talking about int arr[11]={1,2,4,5,6,4,6,4,4,4,9}; int sArr = sizeof arr/ sizeof arr[0]; for(int i=0;i
@qusuto
@qusuto 4 года назад
thanks
@cityvoyage
@cityvoyage 8 лет назад
I watched this one at least 5 times
@mehmetsahin7313
@mehmetsahin7313 6 лет назад
what about now bro?
@tharealog3207
@tharealog3207 4 года назад
@@mehmetsahin7313 ya şimdi kardeşim ?
@dannykogan7009
@dannykogan7009 7 лет назад
god bless Bucky Roberts!!!!
@guoitdreuy
@guoitdreuy 7 лет назад
How come this doesn't work if you use %c for a character rather than %s for a string? Since we are only trying add a single character s....
@michaelcole506
@michaelcole506 7 лет назад
After some playing-around I found that you must, of course, use single quotation marks for your character entry BUT you must also use a 'space' in between your empty entry as the compiler will not like it. I think it's easier the way Bucky does it since you won't have to remember this little rule. #include int main() { int friends; printf("How many friends? "); scanf(" %d", &friends); printf("Friend%c ", (friends != 1) ? 's' : ' ' ) ; //
@arijeettripathy6803
@arijeettripathy6803 5 лет назад
Thanx a lot Bucky!!!
@vestraya
@vestraya 10 лет назад
im confused!!! when do you use "&" for when you assign the value from scanf 1. char lastName[20]; printf("Enter your last name: "); scanf(" %s", lastName); 2. char answer; printf("Do you like bagels? (y/n) "); scanf(" %c", &answer);
@zaharouni1
@zaharouni1 10 лет назад
because lastName it's an array thus we have to use & but answer it isn't
@jamesbrown-yr5cz
@jamesbrown-yr5cz 9 лет назад
you only put & to array, lastName is array because you insert [20] behinde lastName, you dont need to put & if you din put [20] behind lastName, that is the one that decide wheather u need to put & or not
@aleksander60v
@aleksander60v 9 лет назад
james brown No, you DO NOT put it to an array. I think you missunderstood this.
@thegaminglime2870
@thegaminglime2870 7 лет назад
This code is not working, the headers are there as well, just didn't copy them int main() { char lastName[20]; printf("Enter your last name: "); scanf(" %s", lastName); (lastName(0) < 'M') ? printf("Blue Team") : printf("Red Team") ; return 0; }
@biomattic9816
@biomattic9816 7 лет назад
you have to use these brackets [ ] where you want to select char 0 of lastname.
@Anonymous-yb1bm
@Anonymous-yb1bm 5 лет назад
@@biomattic9816 thanks a lot man i really got f*** up
@ewwbananaagain
@ewwbananaagain 9 лет назад
this is great!
@krutomjer
@krutomjer 10 лет назад
Thanks Bucky :)
@Yuri-bt4wl
@Yuri-bt4wl Год назад
YO RED TEAM!
@GMByteJavaTM
@GMByteJavaTM 6 лет назад
Oh-oh, Russian ain't for you hoss XD I mean we got like 3 endings for things when they are counted from 1-10. English has only got the 's' ending.
@moayadyaghi
@moayadyaghi 5 лет назад
Well, in Arabic it's much more complicated. We have the endings like this an ending for singular (works for 1, 20, 100, 1000,... ,11->102, 111->201, 211-302, ...) another formula for two objects an ending for plural (works for 0, 3->10, 103->110, 203->210, ...)
@philspaghet
@philspaghet 6 лет назад
READS LIKE A FRICKING BOOK
@abhijeetckar
@abhijeetckar 6 лет назад
good example
@adrianeu3076
@adrianeu3076 9 лет назад
I'm using Xcode version of C programming to do the challenge. Apparently every time you run the programme, the rand() function will keep on generating same value. Searched internet and found the solution. That is to put srand(time(NULL)) at the start of your code (something to do with seeding.. not sure how it works). Anyone kind enough to explain it?
@uncg7100
@uncg7100 6 лет назад
Rucky Bobberts
@thegaminglime2870
@thegaminglime2870 7 лет назад
Never mind I figured it out
@elektrikpulse61
@elektrikpulse61 7 лет назад
Anyone hear him say that his last name "Roberts" is above "M"? No, just me?
@rossi6388
@rossi6388 9 лет назад
Thanks a lot Bucky for your time, the syntax is not clear, I mean what is after the test is it a ? Or a ; also between truecode and the false code is it a comma or what. Thnx for your time
@bigmacdoubleyouv
@bigmacdoubleyouv 8 лет назад
what about lowercase versus uppercase when it comes to the value of letters? is b greater than or less than A?
@johnzoidberg1844
@johnzoidberg1844 8 лет назад
ALL UPPERCASE < all lowercase
@yingtang9073
@yingtang9073 7 лет назад
than you for your clarification :)
@amanpreetsingh790
@amanpreetsingh790 6 лет назад
Refer to ASCII values, basically the compiler converts them into ASCII value and then compare
@pratiknaik888
@pratiknaik888 6 лет назад
In the last word friends, instead of %s, why cant we use %c since we are substituting only one character s
@babuy8521
@babuy8521 8 лет назад
i am executed 23rd tutorial program, but i am getting only "red team" as output,,,,.............
@shubhamishu1
@shubhamishu1 8 лет назад
True
@joojoo1285
@joojoo1285 7 лет назад
Close and repoen CodeBlocks
@vallabhgulakhe3945
@vallabhgulakhe3945 7 лет назад
write first letter in uppercase then you will get blue team
@wariskn7096
@wariskn7096 7 лет назад
Can we use the statement without printf method. I have done a program but it seems that the output is showing only when I use printf function only. Program is defined below Int main { Int i=0; Name[5]; Printf("enter name:"); Scanf("%s",& Name); (Name[0]='a')?i==5:i==3;//here by using ptrintf the output is obtained,but cannot assign a value :( // Printf("%d",i); Return(0); } The problem is the the value for I have assigned is not printing the output,i must be 5 or 3 but it is showing 0 itself the value I have assigned before.please anyone in this universe help me,bucky are you out there.
@avirajbevli7268
@avirajbevli7268 6 лет назад
a quick question....can we use our "conventional if else" instead of the shorthand if else to run the program?...if yes, then how?...would be grateful to anybody willing to clarify my doubt
@alyskeia
@alyskeia 3 года назад
Why do not we use %c and 's' in place of %s and "s"?
@alexshepler403
@alexshepler403 6 лет назад
would you say I have -1 friends or -1 friend
@neivar4
@neivar4 7 лет назад
My code is exactly like yours and I always get the same team. If lastName starts with a 'N' or an 'R' i always get Red team. Pls help. #include #include #include int main(){ char lastName[20]; printf("Enter your last name: "); scanf(" %s", lastName); (lastName[0] < 'M') ? printf("Blue Team ") : printf("Red Team "); return 0; }
@vallabhgulakhe3945
@vallabhgulakhe3945 7 лет назад
Caput write first letter in upper case of your output then you will get blue team
@jitendradude
@jitendradude 5 лет назад
@@vallabhgulakhe3945 this helped. thank you
@sluttyfuck19
@sluttyfuck19 9 лет назад
What about using the 'x' when its only one letter?
@ZURATAMA1324
@ZURATAMA1324 8 лет назад
Question, could I add a regular if-else statement in printf?
@marcoantonio7648
@marcoantonio7648 8 лет назад
+ZURATAMA1324 I'm wondering this too.
@yingtang9073
@yingtang9073 7 лет назад
I tried, it seems impossible. After I learn more, I will try again. :)
@sangminpark2948
@sangminpark2948 7 лет назад
I'm trying to figure this out as well
@tayyabahmed46
@tayyabahmed46 5 лет назад
I think it is shorthand method to use condition, otherwise if-else statement is a separate function.
@ajay000003
@ajay000003 8 лет назад
what if user has to enter the number of friends. anyone help plz
@George-yn6ze
@George-yn6ze 8 лет назад
i think it would be like this: #include #include int main() { int friends; scanf(" %d",&friends); printf("I have %d friend%s",friends,(friends==1) ? "":"s"); return 0;} I may be wrong though,but I hope I helped you.
@aengnr1
@aengnr1 8 лет назад
correct
@shubhamishu1
@shubhamishu1 8 лет назад
but it is only generating red team as result for any input ?? -_-'
@ajay000003
@ajay000003 8 лет назад
Thnx George
@strssko
@strssko 5 лет назад
in English for number 101 you say friends or friend?
@DerSohnDesAlvaters
@DerSohnDesAlvaters 7 лет назад
I don't get it. No matter what I type I still keep getting red team.
@joshuam2933
@joshuam2933 7 лет назад
Make sure what you're typing starts with an uppercase letter. All lowercase letters have a greater 'value' than all uppercase letters so m > M and since m < M == "false" then it will always print red
@rizaylmz
@rizaylmz 4 года назад
@@joshuam2933 Thanks a lot. I didn't get the first time.
@danpesongco4697
@danpesongco4697 4 года назад
How "?" works? I don't understand it well :(
@karangupta7027
@karangupta7027 8 лет назад
the part (friends!=1) ? "s" : " "; don't we have to write print with s like printf"s"
@aengnr1
@aengnr1 8 лет назад
THIS PART IS ALREADY IN PRINTF COMMAND SO THERE IS NO NEED TO USE PRINTF INSIDE PRINTF
@dzoni97a
@dzoni97a 7 лет назад
can any1 explain me why is he using string for just one letter (s)? why he didnt use char (%c)?
@yingtang9073
@yingtang9073 7 лет назад
I tried use %c instead of %s in his code, but it doesn't work. Am I doing something wrong? int main() { int numberOfFriends=1; printf("I have %d friend%c. ", numberOfFriends (numberOfFriends!=1)? "s":"" ); return 0; }
@sagarjaideepdeshmukh
@sagarjaideepdeshmukh 4 года назад
// (test) ? truecode : falsecode ;(this is the format for short if else statement char lastname[20]; printf("what is your last name? "); scanf("%s",lastname); (lastname[0] < 'm') ? printf("Blue team ") : printf("Red team "); //agar uper capital M dalega toh surname k time bhi capital se start karna int friend; printf("how many friends you have now? "); scanf("%d",&friend); printf("i have %d friend%s ", friend, (friend!=1) ? "s" : "");
@cristinapolonia8698
@cristinapolonia8698 8 лет назад
Can I ask How do I make sure people use numbers only and not characters (or vice versa?). thanks
@aengnr1
@aengnr1 8 лет назад
well you can use printf command to tell them to enter numbers only. or vice versa
@hubble6487
@hubble6487 7 лет назад
make it 30, you never know when a german is going to use your program
@a21123
@a21123 Год назад
printf("%d %s", i+1 , (i+1=1) ? "st" : "" , (i+1=2) ? "nd" : "" , (i+1>2) ? "th" : ""); is there a "correct syntax: for that idea?
@a21123
@a21123 Год назад
I foun that guys printf("%d %s", i+1, (i+1 == 1) ? "st" : (i+1 == 2) ? "nd" : (i+1 == 3) ? "rd" : "th"); it jumps to the other side of tenary function if not true, keeps going like a nested loop until it gets to the "th"
@aengnr1
@aengnr1 8 лет назад
can we use two tests in short-if-else statements?
@michaelcole506
@michaelcole506 7 лет назад
Absolutely! I have been building a large (but useless) program while making my way through these tutorials. I highly recommend trying things and making up your own algorithms for solving problems or organizing data. Anything! As I go along, I keep adding new things I've learned and improving my program. .......Get rid of the one%s that %s yours! ", (actcats == 3) ? "" : "s", (actcats == 3) ? "isn't" : "aren't"); I also put lots of notes in all of these tutorial sources as I write them and use them like a reference book. It's better than reading a book on programming since YOU were the one who made the example.
@mevmevmev
@mevmevmev 9 лет назад
Is there a 'long hand' version of the example in this video? printf("I have %d friends%s, friends, (friends!=1) ? "s" : "");
@hswhite1
@hswhite1 9 лет назад
mevmevmev int friends = 87; if(friends !=1) printf("I have %d friends", friends); else printf("I have %d friend", friends);
@ajaybhosale1848
@ajaybhosale1848 7 лет назад
why it is not working with (friends=1)? "" : "s" this...?
@Crazyboy-tz5ct
@Crazyboy-tz5ct 6 лет назад
I think it is too late but you have to give double equals to sign in (friends==1)
@akalion213
@akalion213 8 лет назад
7:04 Oh boy, if you think English is confusing with that shit try Russian.
@akalion213
@akalion213 8 лет назад
***** Well, I'm a native Russian speaker so I'm not tricked by anything... And it is actually a hard language. Maybe learning it on a very basic level isn't hard, but you can say that about every language.
@akalion213
@akalion213 8 лет назад
***** How good is your Russian? Because it's objectively difficult. Like I said, it's simple on the very basic level, but it's really hard to learn it on a higher level with proper grammar and shit. The alphabet has nothing to do with it.
@akalion213
@akalion213 8 лет назад
***** Well not really. Proper English is A LOT easier to learn than Russian.
@akalion213
@akalion213 8 лет назад
***** Oh for fucks sake, do you even speak Russian? It's OBJECTIVELY harder than some languages.
@akalion213
@akalion213 8 лет назад
***** First off, you didn't answer my question, which leads me to believe that you actually don't speak Russian. Secondly, I already said that I speak Russian, but I also speak Lithuanian, which is an even bigger pain in the ass than Russian. I don't believe it to be harder, I KNOW that it's OBJECTIVELY harder.
@mrgreen6599
@mrgreen6599 7 лет назад
it doesnet work with me !! ----------------------------------------------------------- #include #include int main() { int age; printf("how old are you ?: "); scanf(" %d" ,age); (age>=18) ? printf("you can enter") : printf("you can not enter"); } -------------------------------------- even if write the programme like the usual way it doesn't work !!! #include #include int main() { int numbers; printf("enter your number here: "); scanf(" %d", numbers); if(numbers
@kouhakushiro2884
@kouhakushiro2884 7 лет назад
Try using the & in scanf, in your example like this scanf(" %d",&age); Hope this helps
@mrgreen6599
@mrgreen6599 7 лет назад
thank you so much , hhhh sometimes i be conceited for that i forget some things like that thx againe
@picuinhaXurumelas
@picuinhaXurumelas 8 лет назад
You don't know how portuguese is confusing :)
@marcoantonio7648
@marcoantonio7648 8 лет назад
+Guiango Thinoiras for real, for real...
@Yuri-bt4wl
@Yuri-bt4wl Год назад
🏳‍🌈? It reminds me of this meme
Далее
C Programming Tutorial - 24 - Increment Operator
6:58
Просмотров 170 тыс.
SHIRT NUMBER OR SWIM 🙈💦
00:32
Просмотров 4,7 млн
C Programming Tutorial - 34 - strcat and strcpy
9:06
Просмотров 197 тыс.
C Programming Tutorial - 31 - switch
7:31
Просмотров 161 тыс.
How I program C
2:11:32
Просмотров 728 тыс.
How the C++ Compiler Works
17:55
Просмотров 798 тыс.
C Programming Tutorial - 25 - while Loops
8:29
Просмотров 260 тыс.
C Programming Tutorial - 26 - do while Loops
10:43
Просмотров 258 тыс.
C# Tutorial For Beginners - Learn C# Basics in 1 Hour
1:10:32
GDB Tutorial
55:12
Просмотров 67 тыс.