C Programming Tutorial 51 - If-Else Statement

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

I'm learning a lot from these video. Thanks for posting, I know it takes a tremendous amount of work to make these. I do want to point out here however, in case you are not aware, that these videos seem disjointed. The previous video, #50, used the else statement. And in this video, the code has changed and no longer uses the else statement, but instead uses exit code in each conditional. Maybe you decided to make some changes but for whatever reason, some videos didn't get posted in the right order or some older versions got posted instead of the updated versions. Whatever the case, the videos are still very, very much appreciated. I'm just commenting in case you aren't aware of the issue.

otis
Автор

looks like i am going to have a good c programming class today 😂

yashagrawal
Автор

Thanks again boss. This is way above my head, but it’ll still be here for me later. 😁

theseigemeister
Автор

//Create a game that the user has to guess a number from
//0 to x and output whether the person is correct.

/*ERRORS:
- Segmentation fault: It's basically when you're trying to do
something you're not allowed to do, specifically
accessing some area of memory).

- Implicit declaration of function: We're trying to use a
function that doesn't exist/wasn't included.
*/

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

int main(void)
{
int maxValueGuess = 5;

printf("Guess which number I'm thinking from 0 to %d: ", maxValueGuess);

int guess = -1; //in case of reading error by scanf() checkGuessRange variable will accuse it.

scanf("%d", &guess);

bool checkGuessRange = ((guess >= 0) && (guess <= maxValueGuess));

srand(time(NULL)); /*We pass in NULL to time() function(it just works with null), it returns a value and we pass in this as
the seed of srand().*/
/*Pseudorandom number generator. This gets seeded (é semeado) with some data and outputs a result. (Seed generated from the
clock)*/

int hugeRandNum = rand();

int finalRandNum = hugeRandNum % (maxValueGuess + 1); /*If you need a number whithin a range you can use the modulus operator to do
that. It'll divide the huge integer number by 6, and the remainders possible are 0 to 5!*/

printf("\n(Original random number generated: %d)\n\n", hugeRandNum);

bool palpite = (finalRandNum == guess);

if(checkGuessRange)
{
if(palpite)
{
printf("You're right! I was thinking in %d!\n", finalRandNum);
}else
{
printf("You're wrong. I was thinking in %d, not %d!\n", finalRandNum, guess);
}
}else
{
printf("ERROR. Please try again.\n");
}

return 0;
}
/*
TO DO: Melhorar esse código com loop. Aumentar o range e a cada entrada dizer se tá muito alto ou baixo do número pra adivinhar até acertar
*/

tiagodmota
Автор

just what kind of program can I make by this language
I mean c++ build on this but how can I rech c++ lvl on c????

gz
Автор

Did you hear that they’re going to include a programmer in Frozen 3? They’re planning to call her If-Elsa.

PunmasterSTP
Автор

Man your videos are great but why are you talking like that, you should stop talking like that, change your voice man. that's really annoying.

yassineamgarou
welcome to shbcf.ru