C++ FOR BEGINNERS (2020) - Switch/case statement, Make Calculator application PROGRAMMING TUTORIAL

Поділитися
Вставка
  • Опубліковано 11 вер 2024

КОМЕНТАРІ • 99

  • @CodeBeauty
    @CodeBeauty  4 роки тому +26

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    Code from this video:
    float num1, num2;
    char operation;
    cout > operation >> num2;
    switch (operation)
    {
    case '-':cout

    • @IAmIshanSaxena
      @IAmIshanSaxena 4 роки тому

      I have not understood the "%" part
      please can you explain it in detail...........

    • @IAmIshanSaxena
      @IAmIshanSaxena 4 роки тому

      the bool part

    • @CodeBeauty
      @CodeBeauty  4 роки тому

      Are you familiar with % operator and the way that it works?
      If not, there is a tutorial about operators in C++ in this playlist.
      All of the operators that I mention in that tutorial are used very often and among them '%' (modulo) operator, so please watch that, and that should explain some things.
      If you have any further questions after that, I'll help you.
      It's this tutorial: ua-cam.com/video/RP3BWoep69U/v-deo.html

    • @IAmIshanSaxena
      @IAmIshanSaxena 4 роки тому

      @@CodeBeauty i had already watched it...
      Great explaination....

    • @CodeBeauty
      @CodeBeauty  4 роки тому +4

      Here is commented code for case '%'
      case '%':
      bool isNum1Int, isNum2Int;
      isNum1Int = ((int)num1 == num1);//check if 1st number is an integer
      /*When you cast decimal point number, ex. 5.5, into an int, the value of that int will be 5
      And if you cast 5.0 into an int, the value of that int will be 5 as well
      That means that you can compare int(num)==num, and that will beresult in one of these two options:
      option 1. int(5.5)==5.5, which results in 5==5.5

  • @maryamzia7831
    @maryamzia7831 3 роки тому +16

    Really really thanks for these awesome tutorials. Being a girl I feel really empowered to see you code and it urges me to work even harder.
    I've no words to tell you how much you inspire me. Love you.

  • @yashjadhav6838
    @yashjadhav6838 3 роки тому +9

    This whole playlist is so informative i have learned so many new things watching these videos thank u so much

  • @LayCritic
    @LayCritic 3 роки тому +5

    Your explanations are so adequate!!! Thanks for your hardwork.

  • @traianbadea7389
    @traianbadea7389 4 роки тому +3

    Thank you for your tutorial I could understand this language.

  • @ikilluboy1634
    @ikilluboy1634 4 роки тому +10

    these videos are really easy to understand you are doing an amazing job! also c++ is so similar to python

    • @CodeBeauty
      @CodeBeauty  4 роки тому +16

      That is the best thing that you can tell me because I know how hard programming was for me in the beginning.
      Also, you can apply the logic that you learn in C++ to many other programming languages, because it is going to teach you how things work on a very deep level.
      Some other languages hide that complexity, some don't, but it is easier to learn higher lvl programming language after C++ than vice versa. 🤓

  • @ElmoSyr
    @ElmoSyr 3 роки тому +2

    I was happy to find that I could do the % integer checking with a little more dense code. To me it seems a little tidier and you don't need those additional booleans. But I get why you used them to make it more easier to understand!
    I did it like this:
    case '%':
    if ((int)num1 == num1 && (int)num2 == num2)
    cout

  • @johnwellard3690
    @johnwellard3690 3 роки тому +1

    Hi
    Another brilliant video.
    There is one option that is not considered and that is for the modulo option where num1 < num2. I have written four lines to be included after line 20 which seems to work.
    if (num1 < num2)
    cout

  • @MegaWeixin
    @MegaWeixin Рік тому

    Atleast one video/ one day I'm learning from you.Thanks a million.

  • @painsme2
    @painsme2 3 роки тому +1

    Yeah I noticed the same issue with the letter "e" and if used it does not send the invalid operation message by default. I checked many other letters and it works fine but not for "e".. Thank you for the lessons btw much appreciated.

  • @hackathon-bestmostar273
    @hackathon-bestmostar273 4 роки тому +3

    Well explained, nice!

  • @gidijoeebenezer3177
    @gidijoeebenezer3177 Рік тому

    Hello
    I really admire how deep you are in the programming.
    Can you please take me through some tutorials? I'm a student doing computer science and I have little challenges
    Pleasssssssse

  • @IAMEXTRAZ
    @IAMEXTRAZ 3 роки тому +1

    In the past six hours I have gone from learning how to print hello world to making a calculator app. A lot of these UA-camrs make c++ tutorials but they don't even come close to you!

  • @joseramonlopez1113
    @joseramonlopez1113 3 роки тому

    I liked very much the ending. Just as in the catoons a little devil in a shoulder and litte angel on the other one discussing between each other

  • @OneTakeEverest
    @OneTakeEverest 3 роки тому +2

    great tutorial, but wouldnt it be easier for the cases to just copy and paste all 5 operators' code and just change the '+', etc, and the num1 + num2, etc, or would that mess up the syntax?

  • @esihlesigaqana5980
    @esihlesigaqana5980 2 роки тому

    you are my hero your videos are easy to understand , i'm going to create my own computer too . thank you

  • @lickguitars1276
    @lickguitars1276 Рік тому

    i had to watch this 5 times just to understand it logically, great tutorial btw

  • @neepunpatil5201
    @neepunpatil5201 3 роки тому

    So finally I've built my own calculator Application, thx mam for this tutorial.

  • @joanperisbelles8060
    @joanperisbelles8060 Рік тому +1

    I did that things you say hackers do without the default option and it just jumps one line and after that it shown that long message and the console went out when I pressed other button.

  • @laxus7764
    @laxus7764 3 роки тому +1

    we can figure out if the number is integer or not by typecasting the float value into integer and then subtracting that from the float value
    if the result is zero then the number is integer...is it correct?
    Edit: omg i overdid it..

  • @amberperkins5419
    @amberperkins5419 2 роки тому

    This was extremely helpful!!! Thank you!!!

  • @fastcars393
    @fastcars393 3 роки тому +1

    @CodeBeauty - Just want to compliment you on your videos so far and that you really are a beauty. Second, I'm trying to make a calculator that will ONLY work out the area and perimeter of a circle. Do you have a video on how to do this? I look forward to anything you might have to show me regarding this and I'm really loving your videos so fa, so well done and keep it up! :D

  • @chernorahmadbarry1304
    @chernorahmadbarry1304 2 роки тому +2

    Thank you very much for these lessons. I'm doing c++ this semester and your videos are being really helpful. I have a question concerning this video. You used bool and if statement to convert the % to int. I used the same thing and it worked but I was wondering if there's a simpler way to do it. Because, even though I followed your steps but I didn't understand the isNumInt you used. So I used the concepts you taught on the ASCII table by writing "int(num1)%int(num2)" and I got the same answer without the bool and if statement. I want to know if it's ok to do it like this or is there a difference?

    • @Tomhawk97
      @Tomhawk97 2 роки тому +2

      Yes, there's a huge difference! If you use "int(num1)%int(num2)" instead of an if-else statement, you just transform float numbers into int numbers. Let's see an example: if your program gets the input "10.5 % 3.6" the result will be "10 % 3 = 1" instead of "Not valid!". As you see the result will be misleading, because if you divide (with) a float number, there should be no residue after division. The if-else and the bool is not used for conversion, it's only used to check that the num1 and int(num1) are the same value. (Like 5.0 == 5)

  • @sardarahsan2856
    @sardarahsan2856 Рік тому

    ummm hi saldina...I just wanna add that up till now we have not studied loops so we can't do iterations or repeat the code...we have to run the program again and again...so we could just add goto statement outside the switch which will help repeat the code again and again...Thanks

    • @CodeBeauty
      @CodeBeauty  Рік тому

      Goto is bad practice. I don't know why your teacher is insisting on it, but at least you should remember that 🙌

  • @abdul-azeem-3456
    @abdul-azeem-3456 Рік тому

    Very nice video
    Keep it up!

  • @omaristaitia5628
    @omaristaitia5628 3 роки тому

    its amazing, I really learn , Just Saldina !

  • @ladymorwendaebrethil-feani4031
    @ladymorwendaebrethil-feani4031 2 роки тому

    I didn't understand the bool part that receives the cast value to int.

  • @surVERXD
    @surVERXD 2 роки тому

    The code is nice and all
    but what happens if you divide it by zero the answer is inf
    so
    you can do this code
    case '/':
    if(n2 != 0.0)
    cout

  • @thelionszen3352
    @thelionszen3352 Рік тому

    Thank you for the great videos!
    I'm building the switch statement calculator for class using ifstream and for some reason the last statement always repeats itself. I'm using breaks and a while (!fin.eof())

  • @brandon_wallace
    @brandon_wallace 2 роки тому

    What was that beeping noise while typing the default output string?

  • @LEEJUAN123
    @LEEJUAN123 3 роки тому

    I need a refresher with the other videos.

  • @atanusarkar8384
    @atanusarkar8384 2 роки тому

    Saldina, whatever was hidden behind those **BEEPS**, I'm guessing those were some really good adjectives for our hacker🤣🤣. Thanks anyways for your efforts; I'm so grateful for you.

  • @ROYALNIL_SITE
    @ROYALNIL_SITE Рік тому

    WOW ! Saldina you good make sample "variable" use in programming like dish and glass!
    very thanks
    #ROYALNIL

  • @stormynight4856
    @stormynight4856 Рік тому

    My solution was creating another set of int variables, named int1 and int2
    Then creating an if else statement of "if((int)num1==num1 and (int)num2==num2)
    {int1=num1;
    int2=num2;
    cout

  • @gonzalocorbo9824
    @gonzalocorbo9824 3 роки тому

    thank beautiful for your work. best regards

  • @Yes.Its.
    @Yes.Its. 3 роки тому

    Hello Saldina, I watched your video and tried to write code that checks if insert number has int type or something else, and here what I got : )
    bool isNum1True, isNum2True;
    if (num1 / int(num1) != 1 || num2 / int(num2) != 1) {
    isNum1True = false;
    isNum2True = false;
    }
    cout

    • @Yes.Its.
      @Yes.Its. 3 роки тому

      Ok, it's just wrong (

  • @elaaal7215
    @elaaal7215 2 роки тому

    How we create a calculator with all operations and contain round and square parentheses use a minimum of 3 classes the classes should contain at least one dynamically allocated char array, a dynamically allocated numerical array, a constant field, a static field, and a static method. The members should be class-related. for example [(2*3)^2]/4-(6+2)#3, where x^y means x at power y and x#y means y order root from x, will output 7. the calculator will take the input from the console. The user will have the ability to write equations and entering the app will display the result. The calculator will accept input until the user types ‘exit’ . Can you make a tutorial!! Thank you

  • @a.elitebzj6494
    @a.elitebzj6494 Рік тому

    why other characters such as "^" was not included?

  • @ReLLaKaT316
    @ReLLaKaT316 2 роки тому

    Thank you so much

  • @yummy9554
    @yummy9554 Рік тому

    am new can someone explain this worked or is wrong??
    case '%':
    cout

  • @ryanhood3505
    @ryanhood3505 3 роки тому +1

    It's really hard to code in mobile phone:( It does not work properly. It's so hard to study in this situation which i can't afford to buy laptop or pc. My mind say's "just give up" but here i am still doing my best:|

  • @nicholasjunior7892
    @nicholasjunior7892 Рік тому

    Thanks so much for the knowledge Salina can I get your

  • @JohnDoe-fn1me
    @JohnDoe-fn1me 4 роки тому +1

    Great turtorial. Unusual accent, where are you from? 😊

    • @CodeBeauty
      @CodeBeauty  4 роки тому +1

      I think that I have an Eastern European accent. I hope it’s easy to understand :D
      I currently live in Mostar :)

    • @JohnDoe-fn1me
      @JohnDoe-fn1me 4 роки тому +3

      @@CodeBeauty I see. Anyone who speaks English will understand. Don't you worry. A word of advice. If you are passionate about teaching on UA-cam you just have to be persistent. 12-18 months before your channel will grow in a meaninful way. Also you can try Twitch streaming. Other things too if you need advice. 👍

  • @asadniaz9636
    @asadniaz9636 3 роки тому

    How can we use relational operators in switch function 🤔

  • @seanwestbrook9619
    @seanwestbrook9619 4 роки тому +1

    The videos are wonderful.
    Thanks so much.

  • @user-py3jk5tg4b
    @user-py3jk5tg4b 4 роки тому +1

    Thank you for your tutorial .it's easy to understand. But why
    If i have a number = 1.23
    num-int(num)
    The result doesn't =.23
    But = .229178

    • @CodeBeauty
      @CodeBeauty  3 роки тому +1

      That is a good question, and I wrote the answer to very similar one on another video. I'll link the video that has that question in the comments, and my answer to it, so that might help you to understand this better 😊
      It is a question from Stefan Skoric, where he asked about counting digits of a decimal number, and it is in this video
      ua-cam.com/video/jWISn6pk-XU/v-deo.html

    • @user-py3jk5tg4b
      @user-py3jk5tg4b 3 роки тому +1

      Thanks for explaining that in detail. It's pretty nice from you

  • @mhdjaseem3195
    @mhdjaseem3195 3 роки тому

    thanks, mam💕💖

  • @bielhelp
    @bielhelp 2 місяці тому

    I declared two new int variables instead of using the (int)num1:
    int v1,v2;
    v1 = num1;
    v2 = num2;
    if (v1==num1) {isNum1Int = True;} else {isNum1Int = False;};
    if (v2==num2) {isNum2Int = True;} else {isNum2Int = False;};

  • @gyanendrapalsingh3683
    @gyanendrapalsingh3683 3 роки тому

    I Don't know why ..But i'm getting 7 errors:
    int main()
    {
    float input1, input2;
    char operation;
    cout > input1 >> operator>> input2;
    switch (operation)
    {
    case '-':cout

    • @safak2492
      @safak2492 3 роки тому

      "operation" wrong in "cin" line and swtich section.

  • @ezzy3615
    @ezzy3615 4 роки тому +1

    i didnt get the % error?? why??

    • @CodeBeauty
      @CodeBeauty  4 роки тому

      Give me your code and I'll tell you why. :D :P
      Paste your code here 😊

    • @CodeBeauty
      @CodeBeauty  3 роки тому

      @Afrasyap Hazerfen It is because you are using integer numbers.
      In the first line you declare them as: int int1, int2;
      So your int1 and int2 are of int type, and % is allowed on integers.
      If you declared num1 and num2 as float or double, you wouldn't be able to use % operation on those numbers, and you would get an error.

  • @lodyvermeulen
    @lodyvermeulen 3 роки тому

    why do you always look so beautiful.
    you look even more beautiful with glasses
    i am a big fan of your tetorial c ++

  • @johnrendellcanteras7681
    @johnrendellcanteras7681 3 роки тому

    thank you @codebeauty

  • @imnot9923
    @imnot9923 2 роки тому

    Comment for Algor

  • @rameenbabar3155
    @rameenbabar3155 23 дні тому

    i did this code with static cast #include
    using namespace std;
    int main()
    {
    float num1, num2;
    char operation;
    cout num1 >> operation >> num2;
    switch (operation)
    {
    case '-': cout

  • @jeremy9499
    @jeremy9499 3 роки тому

    she's a very smart beauty

  • @astudent797
    @astudent797 3 роки тому

    // calculator for operators +, -, *, /.
    #include
    using namespace std;
    int main()
    {
    float num1,num2;
    char op;
    cout > op;
    cout num1 >> num2;
    switch (op)
    {
    case '+':
    cout

  • @aa8547
    @aa8547 3 роки тому

    22:00
    English is not my native language, so I couldn't understand just by moving your mouth.

    • @neepunpatil5201
      @neepunpatil5201 3 роки тому

      Shut Fucking Operation, it's ok btw you have built this code spending your precious time what if someone hacks your code. my reaction would be also the same.

  • @hasanferoz2364
    @hasanferoz2364 Рік тому +1

    #include
    using namespace std;
    int main() {
    while (true) {
    float n1, n2;
    char op;
    cout > n1;
    cout > n2;
    cout > op;
    if (op == 'q' || op == 'Q')
    break;
    switch (op) {
    case '*':
    cout

    • @42ott90
      @42ott90 6 місяців тому +1

      lol i tryed too to cast them to int . Just with int num1 , didnt know u can just "cast/convert" (int)num1 . Thanks