C Programming Tutorial – 20 – What about more than two choices?

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

Atouraya1234 says:

Hey Bucky I think your videos are great! I have a question about Code Blocks… I used to type in functions like “printf” and before i finished typing code blocks used to auto detect what I wanted and now it’s not doing that. Do you know how I could get Code Blocks to detect what function I want again? I don’t know what I did in the settings but now I have to type the whole function instead of letting Code Blocks detect it for me.. Thanks!

Marco Pavicic says:

The people with less than 60% are the ones watching ur vids dawg. We aint dumb, just slow. Thanks for the help btw! Comp mid-term tomorrow!

Resid Talibov says:

int age;
char ad;
printf(“adin nedir?”);
scanf(“%s”,ad);

printf(“Nece yasin var?n”);
scanf(“%d”,&age);

if(age<15){
printf(" %s Uzgunem amma bu application senin ucun deil!",ad);
}
else{
printf(" %s Bu vebsayta qebul edildin",ad);
}
Have i got mistake i compile it and it says 0 error but when it opens after the 1st scanf it closes why?
+thenewboston

Dibyendu Db says:

awesome. But why are you always humorous

Ocheencheen daisuki says:

Hurting my feelings Bucky, I am a dumb kid

sangmin park says:

Why don’t you use an ampersand sign before avg in your printf( “Average: %.2f”, avg);

StarMedia StarMedia says:

amazing

Kaks 1&2 says:

hello bucky can u please help me…i felt i did the same code as above but it pops up dialouge box saying stack around variable gender was corrupted. here is what i wrote
#include
int main ()
{
int age;
char gender;

printf(“Enter your age:”);
scanf(” %d”, &age);

printf(“nEnter your gender (m/f):”);
scanf(” %s”, &gender);

if (age >= 18)
{
printf(“welcome to the site”);
if (gender == ‘m’)
{
printf(” Sirn”);

}
else {
printf(” Missn”);
}
}
else
{
printf(“You need to be 18 or over to enter the siten”);
}

return 0;
}

Brennan Jarchow says:

I’m a pro at 13?

Vikkie Singh says:

coolest teacher i have ever seen. thanks dude.

allen castano says:

how am i going to learn if i cannot see the codes. because its too far
tutorial vids from 1 upto 15? is much better because its easy to see..

Leverquin says:

one-size-fits-all

shizyninjarocks says:

“You are dumb” hahahahaha

Jon Ang says:

why do i have to use “else if” if the program runs fine just using “if”?

Tannya Seth says:

sir , i am typing 4 time the grade then i am getting average as 90, like 90 90 90 90 avg= 90; for same pgm?
#include
#include
int main()
{
float grade1;
float grade2;
float grade3;
printf(“enter your grade n”);
scanf(” %f “, &grade1);
scanf(” %f “, &grade2);
scanf(” %f “,&grade3);

float average= (grade1 + grade2 + grade3)/ 3;
printf(“avg is %.2f”, average);

if (average>= 80)
{
printf(” n excellent”);
}
else if( average>=70){
printf(” n good”);
}

else if (average>=60){
printf(” n ok”);

}
else {
printf(” n dumb”);

}

return(0);
}

Luka Rossi says:

Thanks for these tutorials, Bucky

I started from null and now I know so much and even to program myself a little
Thank you! 🙂
P.S. still learning

Shimada - Squad says:

what is the diffrence between using “if” multiple times then use “else” at the last and using “if else” i can’t find the diffrence :/ help !! i am using if multiple times and it works fine

Rustam Safarli says:

well i’m definitely dumb

Factual Six says:

shtatements

Kaks 1&2 says:

hello bucky can u please help me…i felt i did the same code as above but it pops up dialouge box saying stack around variable gender was corrupted. here is what i wrote
#include
int main ()
{
int age;
char gender;

printf(“Enter your age:”);
scanf(” %d”, &age);

printf(“nEnter your gender (m/f):”);
scanf(” %s”, &gender);

if (age >= 18)
{
printf(“welcome to the site”);
if (gender == ‘m’)
{
printf(” Sirn”);

}
else {
printf(” Missn”);
}
}
else
{
printf(“You need to be 18 or over to enter the siten”);
}

return 0;
}

Mauricio Dávalos says:

why is he using SPACE before %f ? I thought you should only use that when sacanning characters with %c

Maaz Bin Mustaqeem says:

Have ever been to Harvard???

Alexey Sapov says:

Anyway you are a good teacher 🙂

Yasin ali says:

we could also use all as if statement. Than why we use else if can anyone tell me?

Ralk Paelmo says:

#include
#include
int main ()
{
printf(“I LAUGHED SO HARD FOR THE “”YOU ARE DUMB”” XD”);

return 0;
}

roger alvarez says:

can you give the link for your website to find the code used in the video. please and thank you

Khan Zahid Rasheed Raja says:

whats wrong with this code anyone help plz ,its just take two grade values instead of 3???

#include
#include
#include “khan.h”

int main()
{
float grade1,grade2,grade3;

printf(“Enter your grades:n”);
scanf(” %fn, %fn, %fn” ,&grade1 ,&grade2, &grade3);
float avg = (grade1+grade2+grade3)/3;
printf(“Average: %.2f”,avg);
return 0;

}

yerrapotu kiran says:

If grades decide intelligence then einstine would be called as dumb for all of his life

Hassan Khan says:

What is this for?

printf (“Average %.2f”)

harmonic spice says:

thanks man i am getting better and better you are good but you pass some stuff but i got anyway

Nidhish Sharma says:

this is offensive to my grades

Rohan Nimbalkar says:

Sir, please don’t record your videos full screen. It becomes easy ton read and understand fast when your videos are cropped and only the coding area is kept.

zmunk says:

can i use (if..else if…else if) statements? Without using an else at the end?

yousuf ak says:

I am new to coding. It was going smooth until loops and I observed a strange thing about it when I reached a program which was to print all prime numbers from 1 to n. There are so many variables declared and I basically want to know how, when and most importantly WHY do we declare so many variables. If someone can explain this, it will definitely be a game changer for me. Thanks in advance.

Asfand Shakeel says:

where can i get this tutorial’s code?

Daski69 says:

Is there any other point to ‘else if’ than faster programs? you could just use a bunch of if-statements right after each other although in that case the program would have to check all of them

HABELFOC _ says:

Ini lebih bagus! lol

int main()
{
float penggal1;
float penggal2;
float penggal3;

printf(“Markah Penggal 1:n”);
scanf(” %f”, &penggal1);

printf(“Markah Penggal 2: n”);
scanf(” %f”, &penggal2);

printf(“Markah Penggal 3: n”);
scanf(” %f”, &penggal3);

float purata = (penggal1 + penggal2 + penggal3) / 3;
printf(“PURATA: %f.2 n”, purata);

if (purata >= 85) {
printf(“Grade An”);
} else if (purata >= 75) {
printf(“Grade B n”);
} else if (purata >= 65) {
printf(“Grade C n”);
} else if (purata >= 55) {
printf(“Grade D n”);
} else {
printf(“Don’t give up! try next time n”);
}

return 0;
}

Tina Sørensen says:

So your website is not buckysroom anymore. So at thenewboston website. Where can I find the codes you are using in your tutorials here?

Yassine Oueslati says:

i Think he’s not using he’s channel anymore :/ .. u were the Best bucky i even seen.
(”And the only bucky in this damn planet n”);

Andrew Highnet says:

ahhahah

Ilm Seeker says:

Pro tip:

instead of:

printf(“Enter the first three grades:n”);
scanf(” %f n %f n %f”, &grade1);
scanf(” %f n %f n %f”, &grade2);
scanf(” %f n %f n %f”, &grade3);

It can be shorten:

printf(“Enter the first three grades:n”);
scanf(” %f n %f n %f”, &grade1, &grade2, &grade3);

Ivan Antunović says:

int main()
{
int age1;

printf(“Enter the age of your first kid. n”);
scanf(” %d”, &age1);

if(age1 >= 16)
{
printf(“Your first child can drive a car in USA. n”);
}else if(age1 >= 18){
printf(“Your first child can drive a car in EU and USA. n”);
}else{
printf(“Your first child cannot drive a car in USA nor in EU.”);
}

return 0;
}

how can I make this code to write “Your first child can drive a car in USA.” only for ages in range of 16 – 17 because whenever I write that age1>16 it never prints “Your first child can drive a car in EU and USA.”

Vineet Ludhani says:

I am getting an error while compiling.. The error is expected expression before ‘%’ token… How do I get past by this error?

Mii Likes Yoshi says:

Is the if statement the same in every language? I learned it in PHP, JavaScript, Java, C++, and Python and they are all very similar.

IndiCoder says:

Doesn’t any grade >90 also means >60 too ? Then why doesn’t the code gets confused? Is it better to mention something like 60

burton 2202 says:

where are the actual codes at? I didnt find on the website

 Write a comment

*

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

Please click below to support us on Facebook!