Sum of two number in c++ programming | c++ coding | programming in c++ language | cpp programming

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • sum of two number in c++ programming language
    c++ coding,
    cpp coding

КОМЕНТАРІ • 150

  • @savitajoshi6834
    @savitajoshi6834 4 місяці тому +40

    C :
    #include
    int main() {
    int x = 5;
    int y = 6;
    int sum = x + y;
    printf("%d, sum);
    return 0;
    }
    Output : 11

    • @drfutato
      @drfutato 2 місяці тому +4

      #include
      int main(void) {
      Int x, y, sum;
      printf(“Enter two numbers: );
      scanf(“%d%d”, &x, &y);
      sum = x+y;
      printf(sum);
      Or, forgo sum altogether and
      printf(x + y);
      return 0;
      }

    • @PrakashK-sg1kv
      @PrakashK-sg1kv Місяць тому

      Bro ur contact number please some doubts

    • @bgmiunbanned230
      @bgmiunbanned230 Місяць тому +1

      ​@@drfutato🎉🎉❤❤

    • @MMeditz-2710
      @MMeditz-2710 Місяць тому +1

      #include
      Int main()
      {
      Int a, b, c
      C=a+b;
      Cout>b;
      }

    • @shridhargovindula3827
      @shridhargovindula3827 22 дні тому

      What’s that

  • @satvikkhare1844
    @satvikkhare1844 8 місяців тому +32

    How can I get 30s of my life back. Do it using pointers.

  • @zee12592
    @zee12592 3 місяці тому +1

    Y bhtt intrsting h yrr m to ab shuru krri hu seekhna i am b com krliya h ab complete but man h to bs seekhna h ye bhi i hope easy rho

    • @aniketroy3034
      @aniketroy3034 2 місяці тому +1

      all the best! it's always good to see a non-techy trying coding

  • @nyssc
    @nyssc 9 місяців тому +53

    You should use
    export inline template requires (Ty1 obj1, Ty2 obj2) { obj1 + obj2; } auto get_sum(const Ty1& obj1, const Ty2& obj2)->decltype(obj1 + obj2)noexcept(noexcept(obj1 + obj2)){
    return obj1 + obj2;
    }

    • @toby9999
      @toby9999 9 місяців тому +8

      Not really.

    • @naszemade
      @naszemade 9 місяців тому +8

      Try hard

    • @wojtekdudek2374
      @wojtekdudek2374 9 місяців тому +1

      True

    • @shahriarlabib000
      @shahriarlabib000 9 місяців тому

      or just use double datatype

    • @kinershah464
      @kinershah464 8 місяців тому +4

      Why? If he wants to add two integers, then he will add two integers, no need for templates. Don't complicate things.

  • @dikkuyadav9042
    @dikkuyadav9042 Рік тому +9

    Very helpful.. thank you so much 🙏

  • @user-zn4uq6cd5f
    @user-zn4uq6cd5f 10 місяців тому +4

    Very help . For you thank you

  • @Salah_-_Uddin
    @Salah_-_Uddin Місяць тому +2

    Thanks, it works.

  • @djlystics
    @djlystics 6 місяців тому +4

    What about if you want the user to be able to enter more numbers for the sum without knowing how many numbers he will enter? Asking because that’s my homework for this week. Trying to figure out how to write a program for multiple numbers where as it outputs sum of even numbers, sum for odd numbers, and total sum.

    • @TTony
      @TTony 6 місяців тому

      Use the "for" loop.
      int n, x, s=0;
      cin >> n;
      for(int i=1; i> x; // this will be read n times
      s = s + x; // adds the current number to the sum
      }
      Let's say you have 4 numbers (3 7 9 18). i (from the for loop) will start out as 1, it will check if it's smaller then n (which in this case will be 4, cause we have 4 numbers) then it will execute what's inside the for loop. Then i will increase and so on.
      I'm guessing you know how to check if a number is odd or even using if statements.

    • @TheSpacePlaceYT
      @TheSpacePlaceYT Місяць тому +2

      Add a do while loop so that until the user enters a sentinel value, they will continuously add numbers.
      Here's a way of doing that in English/code terms.
      int number;
      int sum = 0;
      do{
      cout > number;
      sum += number;
      }while(number != -1)
      cout

    • @sws212
      @sws212 День тому

      ​@@TheSpacePlaceYTUhh... You didn't put a limit or any context why they need to put -1. Your code literally never stops otherwise.

  • @MARKUS-mc5ez
    @MARKUS-mc5ez 10 місяців тому +12

    in cout, remove the quotes where a+b so the numbers that you entered instead of letters will be output

  • @Neonili
    @Neonili 8 місяців тому +2

    I was always doing cout no. 1;
    And then repeat with no. 2 but i see that i can just do cin >> a >> b;

  • @neer471
    @neer471 25 днів тому +11

    meanwhile in python
    a=input(int(enter first num))
    b=input(int(enter second num))
    print(f"sum of {a} and {b} is", a+b )
    amd thats all

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

      Less readable

    • @Bird53826
      @Bird53826 20 днів тому

      Slight correction because u reversed int and input and forgot quotation marks:
      a = int(input("Enter the first number: "))
      b = int(input("Enter the second number: "))
      print(f"The sum of {a} and {b} is: {a + b}")
      or
      print(f"The sum of {a} and {b} is: ", a + b

    • @Wutheheooooo
      @Wutheheooooo 20 днів тому

      @@Bird53826 used f string, and then put the a + b outside, what's the point?

    • @Bird53826
      @Bird53826 19 днів тому +1

      @@Wutheheooooo because without the f string {a} and {b} wouldn't work

  • @maliksami133
    @maliksami133 10 місяців тому +4

    Very easy

  • @we_four_DAPS
    @we_four_DAPS 21 день тому

    Python
    a=input(int(enter first number))
    b=input(int(enter second number))
    Print(f"sum of {a} and sum of {b} is" ,a+b)

  • @user-wl3bi6sv8k
    @user-wl3bi6sv8k 9 місяців тому +5

    Fun to code

  • @joshnathanielarcilla6127
    @joshnathanielarcilla6127 11 місяців тому +21

    Sup fellow coder that uses android to code 👊😊😊

    • @kahumaisaac7699
      @kahumaisaac7699 11 місяців тому +1

      Bro wats up

    • @kahumaisaac7699
      @kahumaisaac7699 11 місяців тому +1

      I need some help

    • @joshnathanielarcilla6127
      @joshnathanielarcilla6127 11 місяців тому

      ​@@kahumaisaac7699why bro? Do you have any troubles in your code?

    • @maneee4263
      @maneee4263 7 місяців тому

      what u need help with
      @@kahumaisaac7699

    • @dylanisaking
      @dylanisaking 7 місяців тому +5

      I would genuinely rather walk on burning coal than code on mobile, no offense

  • @kahumaisaac7699
    @kahumaisaac7699 11 місяців тому +7

    Me it has failed

  • @virno69420
    @virno69420 6 місяців тому +3

    Use correct initialization int a{}, etc.

    • @RetroFlexXx
      @RetroFlexXx Місяць тому

      ?

    • @lackahs
      @lackahs Місяць тому

      @@RetroFlexXx it's direct list initialization, initialize ur variables

  • @Fvlyme
    @Fvlyme 4 місяці тому +1

    But you can make it with "switch" and "case" or also "if" and "else"

  • @Aryanshiva-he5ec
    @Aryanshiva-he5ec 10 місяців тому +9

    bro 1 error is generating

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

    the horizontal and vertical whitespacing in this code is making me have a conniption

  • @Merovingien514
    @Merovingien514 10 місяців тому +8

    Lol, std::cout instead of using namespace std😅

    • @toby9999
      @toby9999 9 місяців тому +2

      It's not funny. Both are correct.

    • @Merovingien514
      @Merovingien514 9 місяців тому +4

      @@toby9999 For a beginner programmer, yes, but in real projects, using namespace std can consume memory.

    • @kinershah464
      @kinershah464 8 місяців тому +1

      ​@@Merovingien514consume memory? I don't think so.

    • @virno69420
      @virno69420 6 місяців тому +6

      ​@@Merovingien514It doesn't require memory? The reason it's considered bad practice is because you're likely to get naming collision between functions. That's why they made std namespace.

  • @user-hd4hx3ev4k
    @user-hd4hx3ev4k 5 місяців тому +1

    Where is the enter button in the phone

  • @CripsyBanks
    @CripsyBanks 5 місяців тому +1

    This music is a W

  • @Otakuisland237-km4tp
    @Otakuisland237-km4tp 23 дні тому

    Please 🙏 what is the name of the compiler I are using plz

  • @digitalmachine0101
    @digitalmachine0101 9 місяців тому +1

    Thanks

  • @koushikreddy7621
    @koushikreddy7621 8 днів тому

    #include
    int main(){
    int a = 10;
    int b = 25;
    int c = a+b;
    std::cout

  • @NWABUISIJAHSWILL
    @NWABUISIJAHSWILL 7 днів тому

    Please i want to learn how it works

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

    Most easy program

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

    I don’t think “using namespace std” is a healthy convention. In a larger codebase, you might accidentally overwrite one of the std functions if someone unknowingly writes a function with the same function name as a common std function

  • @BlockHead-mo8co
    @BlockHead-mo8co 2 місяці тому +1

    App name?

  • @AadityaBhowmick
    @AadityaBhowmick Рік тому +32

    It would have been better if you wrote:
    cout

    • @RaoRawal786
      @RaoRawal786 11 місяців тому

      Nyc kia programming hwy apki well-done

    • @user-zx5xx4qu1h
      @user-zx5xx4qu1h 10 місяців тому +2

      it would be better to write
      cout

    • @AadityaBhowmick
      @AadityaBhowmick 10 місяців тому

      @@RaoRawal786 kyun yaar isme galat kya hai? main abhi bhi sikh raha hun class 8 mein hu mein

    • @AadityaBhowmick
      @AadityaBhowmick 10 місяців тому

      @@user-zx5xx4qu1h yeah that can be done either

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

    c++ k program kha pr bnte h

  • @user-oe5sr2ef5l
    @user-oe5sr2ef5l 2 місяці тому

    Что такое return и надо ли это убрать?

  • @vishnutejchennuru8996
    @vishnutejchennuru8996 Місяць тому

    guyz i wanna be ethical hacker what coding language should i learn?

  • @EasyCompile
    @EasyCompile Місяць тому

    I simply skipped the video because you did not enter a space between the include to the iostream library

  • @schoolboy6706
    @schoolboy6706 3 місяці тому

    what about the random sum?

  • @user-lu7ns3ys1n
    @user-lu7ns3ys1n 8 місяців тому +3

    What name of the app

    • @Sobhancraft
      @Sobhancraft 6 місяців тому

      C++ bruh 😎😂😂😂😅😅

  • @user-ql3hl2ne1t
    @user-ql3hl2ne1t 5 місяців тому +1

  • @Sigma_babbon
    @Sigma_babbon 6 місяців тому

    can you make a video about x, and y

    • @dandn3907
      @dandn3907 5 місяців тому

      Yes we can by using pointers 👌🏻

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

    Taking a look at c++ and im already getting brainf###

  • @jhnjbs
    @jhnjbs 8 годин тому

    purna

  • @tengiztayugan9926
    @tengiztayugan9926 День тому

    No need return 0

  • @sajinipraveen1620
    @sajinipraveen1620 Місяць тому +1

    App name???

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

    How the battery Percentage increases while the program is runned 😂

  • @MrTrader-om4cm
    @MrTrader-om4cm 2 місяці тому

    Konsi app hai bhai

  • @mahidahiya6008
    @mahidahiya6008 6 місяців тому

    jse c program turbo c or bnte h usi trha c++ kha bnte h

    • @fachoyt9686
      @fachoyt9686 4 місяці тому

      C++ code b Turbo per run ho jata hai but try Dev C++, it is much better than Turbo.

  • @_____2525
    @_____2525 9 місяців тому +2

    very hard algorithm

    • @firecandys
      @firecandys 8 місяців тому

      its the easiest one

  • @TheTrueVoid861
    @TheTrueVoid861 3 місяці тому +1

    In C this program looks like this:
    #include
    int main()
    {
    int a, b, sum;
    printf("Enter two numbers: ");
    scanf("%d%d", &a, &b);
    sum = a + b;
    printf("a + b = %d", sum);
    return 0;
    }

  • @PerumalC-me6fg
    @PerumalC-me6fg Годину тому

    Instagram program

  • @siyabbasha8859
    @siyabbasha8859 6 місяців тому

    Bro substraction

  • @ffjeetuop2938
    @ffjeetuop2938 2 дні тому

    Yeueu;

  • @LilxianGAming
    @LilxianGAming 5 місяців тому

    What apps do u use?

  • @kashishmanzoor120
    @kashishmanzoor120 Рік тому +2

    Ye kon sa app h bhai ?

  • @surendar4903
    @surendar4903 11 місяців тому +1

    Bro in which app?

  • @youssefsh333
    @youssefsh333 3 місяці тому

    what program is this

  • @Mooproxy
    @Mooproxy 9 місяців тому +1

    Using namespace std, declaring all your variables at the top of a scope block, and using a comma to declare multiple things on one line are all horrible practices in C++.

    • @toby9999
      @toby9999 9 місяців тому +1

      Says who? You?

    • @kacperek3594
      @kacperek3594 9 місяців тому +1

      Why? xD

    • @kinershah464
      @kinershah464 8 місяців тому +1

      Using namespace std is fine for such simple programs. Multiple declarations separated by comma is also fine, it's valid syntax.

  • @talhamahmood6531
    @talhamahmood6531 10 місяців тому

    twenny one

  • @gowrishx-darivazhagan3749
    @gowrishx-darivazhagan3749 Рік тому +1

    Hi

  • @softwaredynamicsolutions
    @softwaredynamicsolutions 10 місяців тому

    👍

  • @filomek
    @filomek 5 місяців тому

    💀

  • @user-fx3tu1nw7v
    @user-fx3tu1nw7v 5 місяців тому

    Wrong this code 😢

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

    11

  • @rovinyadav4191
    @rovinyadav4191 9 місяців тому +1

    Error

  • @Omimanono19
    @Omimanono19 9 місяців тому +1

    Fun to code

  • @NWABUISIJAHSWILL
    @NWABUISIJAHSWILL 7 днів тому

    Please i want to learn how it works

  • @BlockHead-mo8co
    @BlockHead-mo8co 2 місяці тому

    App name?