C Programming Tutorial - 19 - if else

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

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

[ In C programming ]

victormilan
Автор

I learned more in a few hours of these videos than two months of classes. Thanks!

billdipperly
Автор

I Love you,   dude!
The way you teaching us is nothing but a smooth ride along C language.
This is the funniest way of representing C basics I`ve ever seen!:)
P.S. and also easy to understand, highly recommend, people!!

bulid
Автор

Videos are helpful but I think font size should be little larger for a better view.

DagaratWork
Автор

i'm here now guys, i understand this now, just doesn't used to write the code yet, need to practice and practice it, wish me good luck guys, we're on the same boat

jamesbrown-yrcz
Автор

This is so cool. Very similar to php. Now I understand what else means! Thanks

bestbuildpc
Автор

Excuse me. There is no option for me. I sexually identify as an attack helicopter.

octopushorse
Автор

I have to complete this tutorial till 19th oct 2020 (in 2 days) for my test. my teacher completely blew this over me, so i have to study from here.
WISH ME LUCK

vastrashastra
Автор

I'm glad that someone took the time to make these tutorials for free! bucky I'm glad you do what you do, so keep it up. I'm 11 by the way[Not joking]. I want to learn the basics of C to help me when I get my arduino. 


lol I spend too much time on my computer.

jaydownlink
Автор

This video would trigger so many people if it came out in 2017 and the idiots who think non-binary, etc. is really a thing saw it.

blakeortiz
Автор

but even if you don't trype f for female, and use like: s that will be "else" too cuz you didn't make char f anywhere O.o right?

Leverquin
Автор

For those who are interested I thought putting the code where it asks for your gender inside the if statement, because it's redundant to ask for your gender if you're underage anyway. Like this:

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);

printf("\nYou may enter this website ");

if(gender == 'm'){
printf("dude!");
}else{
printf("m'lady");
}

}else{
printf("Nothing to see here!\n");
}

return 0;
}

ScantaniouslyCombust
Автор

/ newboston, you are great...thank you for your tutorial
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
b=3;
clrscr();
printf("if you like this channel type '3' if not, type any no : \n", a);
scanf(" %d", &a);
if(a==b)
{
printf("I love this channel it is awesome for a noob like me");
}
if(a!=b)
{
printf( "I hate thenewboston ");
}
getch();
}

josejerry
Автор

Thanks for the tutorial. I would like to ask, the gender question is nested inside the equal or above 18 condition, if the condition is below 18, why the sequence has to go to ask the gender? It didn't happen when I coded in Pascal.

cityvoyage
Автор

You could literally type in any character for the gender and it would output "m'lady" if >= 18, right?

alexschulte
Автор

I'd add the gender question inside the first "if" brackets, so if ur under 18 it isn't even asked

int age;
char gender;

printf("Whats ur age?\n");
scanf(" %d", &age);


if (age >= 18){

printf("Whats ur gender? (m/f)\n");
scanf(" %c", &gender);

if (gender == 'm'){
printf("You may enter this website, dude!\n");
}
if (gender == 'f'){
printf("You may enter this website, girl!\n");
}
}else{
printf("Nothing to see here.\n");
}

caioc
Автор

Is it really necessary to put the else statement on the same line as the closing }curly bracket?

johnzoidberg
Автор

@thenewboston how are u recording ur videos, what program are u using?

Footballistaas
Автор

Whats wrong with this code? I made a simple calculator for 4 operations and when i press anything except 4 it goes to multiplication and doesnt multiply the numbers or the operation it was meant to do:

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

int main(){
system ("color 0B");
float a, b, numberforoperation;
float sum=a+b;
float sub=a-b;
float div=a/b;
float mul=a*b;
printf("Simple calculator with two numbers.");
printf(" \n \n \n 1-Addition\n 2-Subtraction\n 3-Multiplication\n 4-Division \n");
scanf(" %d", &numberforoperation);
if(numberforoperation=='1'){
printf("Enter two numbers you want to add together\n");
scanf(" %f", &a);
scanf(" %f", &b);
printf("Result: %f", sum);

}else if(numberforoperation=='2'){
printf("Enter two numbers you want to subtract \n");
scanf(" %f", &a);
scanf(" %f", &b);
printf("Result: %f", sub);

}else if(numberforoperation=='3'){
printf("Enter two numbers you want to divide \n");
scanf(" %f", &a);
scanf(" %f", &b);
printf("Result: %f", div);

}else{
printf("Enter two numbers you want to multiply \n");
scanf(" %f", &a);
scanf(" %f", &b);
printf("Result: %f", mul);


}


return 0;
}

ImNotADrug
Автор

My code is not running the first printf statement whenever i type Lester.
#include <stdio.h>
#include <stdlib.h>

int main()
{

char name[20];

printf("Who are you?\n");
scanf(" %c", &name);

if (name == 'Lester'){
printf("Sorry, Lester you can't use this name.\n");
}else{
printf("What are you looking for?\n");
}

return 0;
}

lestercute