Buckys C++ Programming Tutorials – 8 – if Statement

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

41 responses to “Buckys C++ Programming Tutorials – 8 – if Statement”

  1. Aman Jain Avatar

    #include <iostream>
    using namespace std;
    int main (){
    cout <<" welcome to the world of simple calculations nn";
    int a,b,c,d,e,f,x,y;

    cout << "press 0 to continue or any other no. To quitnn" ;
    cin>> y;

    if (y==0){
    cout << " welcome nn";
    cout << "enter a numbernn";
    cin>> a;

    cout << "enter a another numbern";
    cin>> b;

    cout << " press 1 to add 2 to sub 3 to multiply and 4 to divide" << endl;
    cin>> x;
    }else {
    cout << "goodbye, have a nice day" << endl;
    }
    c = a+b;
    d = a-b;
    e = a*b;
    f = a%b;

    if (x==1){
    cout << "the addition of the nos you entered is" << c << endl;
    }
    if (x==2){
    cout << "the subtraction of the nos you enterd is << d << endl;
    }
    if (x==3){
    cout << "the multiplication of the nos you enterd is << e << endl;
    }
    if (x==4){
    cout << "the division of the nos you enterd is << f << endl;
    }
    if (x>4){
    cout << "goodbye, come back later" << endl;
    }
    return 0;
    }

    I know there are a bit of bugs…but help me with the division…i think thats causing a bit of problem. Anyways, a rough program for simple calculator…rate it please…it would b helpful

  2. Juicy Thrax Avatar

    should I be taking notes

  3. BARUA ARKA Avatar

    who is here now in aug ?
    and 21 years old?
    hands up

  4. Rialey Kelly Avatar

    Its always the 6th line of code "[" by itself that C++ says its wrong????

  5. Hassan Ishfaq Avatar

    besides english is not my native language i just know it communicational but you sound me so familiar and yeah u are awesome.

  6. surviving gamer Avatar

    I made an advanced calculator that can add, subtract, multiply, divide or give the remainder of 2 numbers with all of the knowledge from up until this point and I would like to hear your opinion :D:

    #include <iostream>using namespace std;
    int main()
    {
        int a;
        int b;
        int c;    cout << "Hello, this is my advanced calculator. n n Please enter a number n";
        cin >> a;    cout << "You have entered " << a << " n Please enter a mathematical symbol by choosing a number n Choose 1, 2, 3, 4 or 5 to add up, subtract, multiply, ";
        cout << "divide or get the remainder of the division respectively n";    cin >> b;
        cout << "You have entered " << b << " meaning that you will ";    if (b < 2){
                cout << "add up a number with another n Now please choose a second number";
                }
         if (b == 2){cout << "subtract a number from another number" << endl;}    if (b == 3){cout << "multiply a number with another number" << endl;}    if (b == 4){cout << "Divide a number with another number";}     if (b == 5){cout << "get the remainder of the division of the two numbers not the division just the remainder n n";}     cout << "Now please add the third number to get your answer n";
         cin >> c;     cout << "The answer the the question is ";     cout << a;
                if (b == 1){
            cout << " + ";
                }            if (b == 2){
            cout << " – ";
                }            if (b == 3){
            cout << " * ";
                }            if (b == 4){
            cout << " / ";
                }
                if (b == 5){
                    cout << "Get the remainder of number 1 and number 2";
                }     cout << c << " = ";       if (b == 1){
            cout << a + c;
                }            if (b == 2){
            cout << a – c;
                }            if (b == 3){
            cout << a * c;
                }            if (b == 4){
            cout << a / c;
                }
            if (b == 5){
                cout << a % c;
            }}

  7. Yourfirstnightmare Roblox Avatar

    A quick powerlevel scouter 🙂
    If you guys didn't learn else if it's basically like if the first if statement wasn't true then try another test.
     
    #include <iostream>
    using namespace std;
    int main() {
    int powerlevel;
    cout << "VEGETA WHAT DOES THE SCOUTER SAY ABOUT HIS POWERLEVEL! ";
    cin >> powerlevel;
    if (powerlevel > 9000) {
    cout << "ITS OVER 9000!!!!!!!!";
    }
    else if (powerlevel < 9000) {
    cout << "It's lesser than 9000…";
    }
    return 0;
    }

  8. Don't Click The Cookie. Avatar

    I bet there are game plugin scripters

  9. Don't Click The Cookie. Avatar

    Oh god we are being raided buy javascripters!

  10. Kastr3o Avatar

    #include <iostream>
    using namespace std;

    int main()
    {
    int x;
    cout << "Enter a number that is greater than 56 " << endl;

    cin >> x;

    if (x > 56)
    {
    cout << "True..!!! :)" << endl;
    }

    return 0;

    }

  11. ReactioN Avatar

    My simple thing <(")
    #include <iostream>

    using namespace std;

    int main()
    {
    int Age;
    cout << "How old are you ? n";
    cin >> Age;

    if (Age<17){
    cout << "You should not go here";
    } else {
    cout << "Welcome to the website !";
    }

    return 0;
    }

  12. top 10 Detrax Avatar

    #include<iostream>
    using namespace std;
    int main()
    {
    int a=55;
    int b=66;
    if(a<b){
    cout<<" Bcky is pretty cool huh"<<endl;

    }
    return(0);

    }

  13. top 10 Detrax Avatar

    hit like if you're learning c++ in 2k17 xD

  14. R41NY Avatar

    int main()
    {
    int a=8;
    int b=9;
    int c=a+b;

    if(c=18){
    cout << "YEEEY";
    }
    return 0;
    }
    idk why even though it is wrong, it keeps showing the message :c

  15. laukam79 Avatar

    Bucky is really AWESOME!! 🙂

  16. Adeola Reid Avatar

    Hi was wondering if anyone could help me. The screen that pops up when you run the code doesn't stay up in mine after I input the variables. i know i suppose to remain to output a message to the user but it instantly closes.

  17. Nebil Gokdemir Avatar

    I studied your java and now c++
    All I can say you are really awesome:)
    Thanks

  18. MJ Sanchez Avatar

    BUCKY IS AWESOME !!!

  19. Juan Ortega Avatar

    Awesome content, but can you give me a real scenario as to when ir in what setting I would have to use this function in a real program?

  20. spinningninja2 Avatar

    I learned java before C++ and if statements are my favorite part. Literally everything changes when they are introduced. You go from barely doing simple arithmetic to being able to make a freaking text story/ puzzle!

  21. Ibrahim Al Malluhi Avatar

    thank you so much you are awesome!!!!

  22. Sara Tokic Avatar

    Bucky is awesome anyway :p

  23. totongsaipul Avatar

    Yes, BUcky is awesome !!

  24. Tejan Gandhi Avatar

    awesome.. bucky great job, liked your all videos, devloped a good, a lot good approach in C++ only because of you, thanks, you are ""
    pretty cool huh!!""

  25. Linkin Pаrk Avatar

    GUYS!!!! write this code!!!!
    while (7 < 8) {
    cout << "DO IT!!!";
    }

  26. Siddhant Sharma Avatar

    this is really cool! play it at 1.5X and you will still be able to comprehend!
    thanks bucky XD

  27. Darion Chandoo Avatar

    i am getting trouble with this code. it prints out all the answers for each stand.

    #include <stdlib.h>
    #include <iostream>
    #include <string>

    using namespace std;

    int main()
    {

    char stand;

    float spectators,revenueA,revenueB,revenueC,revenueD;

    cout << " Enter the stand(A,B,C,D):";
    cin >> stand;

    cout << " Enter the number of spectators: ";
    cin >> spectators;

    if (stand=='A'){
    revenueA = spectators * 50;
    cout << " The revenue of the stand is : "<<revenueA<<"n";
    }

    if (stand=='B');{
    revenueB = spectators * 75;
    cout << " The revenue of the stand is : "<<revenueB<<"n";
    }

    if (stand=='C');{
    revenueC = spectators * 100;
    cout << " The revenue of the stand is : "<<revenueC<<"n";
    }

    if (stand=='D');{
    revenueD = spectators * 200;
    cout << " The revenue of the stand is : "<<revenueD<<"n";
    }

    system ("PAUSE");
    return 0;
    }

  28. Ognjen Tasic Avatar

    can you do the following?

    if (5+8 == 9)

  29. Ege Palamutlu Avatar

    this guy is awesome

  30. RUCH Avatar

    Pretty cool huh.
    This guy rox

  31. SGIT BWAIP Avatar

    #include <iostream>
    using namespace std;
    int main()
    {
    cout << "Hello. nI am C.I.P.S.S. I will ask a series of questions that are answered by pure logiic. You, who is hungry for challenge, nwill answer using the numbers 1 & 2." << endl;
    cout << "scenario #1. nYour home is falling due to the shockwave of a nuclear explosive. nAs you attempt an escape, you find a section of 3 three halls. one leads outside, nOne to the sunroom, nThe last to the cellar. the hallway to the cellar goes past the kitchen. as you head outside the hallway collapses! nnPress 2 to go into the sunroom press 1 to go to the cellar" << endl;
    int a;
    cin >> a;
    if (a < 2)
    {
    cout << "Correct! nThe cellar would protect you after the colapse of your home. " << endl;

    }
    else
    {
    cout << "BEEEEEP!!! The glass around you shattered, leaving you completely exposed to the toxins. you died." << endl;
    int b;
    cin >> b;
    return 0;
    }
    cout << "Well done, human.(i wish i had a head like yours:{)nBecause your house is collapsed on top of you,nthere is hardly a way out. nThere are a few shovels and axes by the wall." << endl;
    cout << " BUt the house has partially covered them in wood.nnPress 2 to clear it janga style?nOr press 1 to clear it top to bottom." << endl;
    int c;
    cin >> c;
    if (c > 1)
    {
    cout << "Correct! Who knows what is weighing down on that wood, you got the shovels and axes." << endl;
    }
    else
    {
    cout << "BEEEEEP! you died cuz the wood fell on ya. Yay for the barbaric way, eh?" << endl;
    int d;
    cin >> d;
    return 0;
    }
    cout << "how do you get out? you check both pillars for the wieght both are supporting.nnPress 1 to dig on the side of the loose pillar.nPress 2 to dig on the side of the tight pillar." << endl;
    int e;
    cin >> e;
    if (e < 2) {
    cout << "CORRECT! good job man! (I didn't expect you to get it this far:*( )" << endl;
    }
    else
    {
    cout << "BEEEEEEP! YOUR DEAD!! The resedue that the pillar supported fell on you. You should probably research pillars." << endl;
    int f;
    cin >> f;
    return 0;
    }
    cout << "Congrats! you have made it thus far, i'll give you this.nHUMANS ARE BETTER THAN COMPUTERS.nI'll stop the rise of A.I.!(sobbs and wails) You've got another problem though.nYou must find a fallout shelf before the radiation spreads. nPress 1 to go to a fallout shelf.nPress 2 to die of every cancer in the world" << endl;
    int g;
    cin >> g;
    if (g < 2)
    {
    cout << "Darnit! you are as smart as i thought. i was trying to make sure your 'intelligence' was just a coincidence. Carry on.:{" << endl;
    }
    else
    {
    cout << "I knew you were stupid! i knew you were just pressing randumb numbers.nyup.nyou died of every cancer in the world." << endl;
    int h;
    cin >> h;
    return 0;
    }
    cout << "scenario #2nA tsunami is headed right to you. you live on the top floor of a brand new brick + mortar apartment building.nIf you stay in your apt. you will fall 100's of feet to your sad death.nnPress 0 to use the elevatornPress 2 to fill with adreniline and survive the jump to your car.nPress 1 to take the stairs. you may use any combination." << endl;
    int i;
    cin >> i;
    if (i = 2)
    {
    cout << "MANLY YOU ARE. you succesfully jumped from the top of your staircase to the bottom and in to your car." << endl;
    }
    else
    {
    cout << "too late! you got washed away like a nomad. either that or you fell to your death." << endl;
    int j;
    cin >> j;
    return 0;
    }
    cout << "you must now decide were you must go to escape thenTSUNAMIn" << endl;
    cout << "Press 1 to go as far away from the shore as possible.nPress 2 to go to the nearest, and tallest mountain you know of" << endl;
    int k;
    cin >> k;
    if (k = 2)
    {
    cout << "you will survive japan, slave of my test.nYou have not died yet;" << endl;
    }
    else
    {
    cout << "awe… your tiny wheels were just not spinnin' fast enough to beat dem rollin' waves" << endl;
    int Q;
    cin >> Q;
    return 0;
    }
    cout << "You have not fully killed the kller wave.nnPress 2 to climb the mountainnPress 1 to drive up then climb the mountain." << endl;
    int l;
    cin >> l;
    if (l = 1)
    {
    cout << "that's kinda lazy but it's tha fastest way up. unless your fat." << endl;
    }
    else
    {
    cout << "your little legs were just not rollin fast enough to escape dem rollin' waves." << endl;
    int m;
    cin >> m;
    return 0;
    }
    cout << "as you roam up the mountain,nYou need to find a place to sheild yourself. several man sized trees and large rocks.nnPress 2 to hide behind a treenPress 1 to hide behind a rock" << endl;
    int n;
    cin >> n;
    if (n = 1)
    {
    cout << "YOU LIVED THROUGH THE TSUNAMI! I am proud of you." << endl;
    }
    else
    {
    cout << "the water uprooted the tree and it fell on you. " << endl;
    }
    cout << "scenario #3nAs you drive home, your car must drive on a wooden bridge, which,nSorry for you,nCollapsed.nYou and your van are now floating the arkansas river in the middle of the night the longer stay in the further you go from civilizationn hw do you want to get out?nnPress 1 to escape through the windownPress 2 to go through the trunk." << endl;
    int o;
    cin >> o;
    if (o = 2)
    {
    cout << "Yay for you.(i can no longer take it. It's so humiliating on my part) you got out of the sinking van, sniff*" << endl;
    }
    else
    {
    cout << "well poo! your hips got stuck in the barely unrolled windows. doncha know when the car is sinkin' ya can't operate the electric features." << endl;
    int p;
    cin >> p;
    return 0;
    }
    cout << "you are on the verge of severe hypothermia.nnPress 2 to run around.nPress 1 to build a fire." << endl;
    int q;
    cin >> q;
    if (q = 1)
    {
    cout << "Well done! You are quite knowledgeable. nHad you ran, you would have fallen into the river." << endl;
    }
    else
    {
    cout << "No matter how long you ran you could not warm up. in fact,nYou seemed to be light-headed.nBlinded by fatigue, You tried to find the road, and the river was right in front of you.nIt is quite the drop, and quite shallow.nFWEEWWWW, SMACK!nYou done did felled inter tha river" << endl;
    int r;
    cin >> r;
    return 0;
    }
    return 0;
    }
    thank you master…

  32. DummYtEsT 123 Avatar

    The huh is now a meme by this point

  33. Snug Life Avatar

    Just finished lesson 8.

  34. Sam Dove Avatar

    is it me or does this feel like a mix of java and python

Leave a Reply

Your email address will not be published. Required fields are marked *