Sum of two number in c++ programming | c++ coding | programming in c++ language | cpp programming
2022 ж. 1 Там.
314 374 Рет қаралды
sum of two number in c++ programming language
c++ coding,
cpp coding
sum of two number in c++ programming language
c++ coding,
cpp coding
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
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; }
Not really.
Try hard
True
or just use double datatype
Why? If he wants to add two integers, then he will add two integers, no need for templates. Don't complicate things.
C : #include int main() { int x = 5; int y = 6; int sum = x + y; printf("%d, sum); return 0; } Output : 11
How can I get 30s of my life back. Do it using pointers.
Very helpful.. thank you so much 🙏
Use correct initialization int a{}, etc.
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.
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.
❤
Fun to code
c++ k program kha pr bnte h
Very easy
This music is a W
Very help . For you thank you
in cout, remove the quotes where a+b so the numbers that you entered instead of letters will be output
Where is the enter button in the phone
Sup fellow coder that uses android to code 👊😊😊
Bro wats up
I need some help
@@kahumaisaac7699why bro? Do you have any troubles in your code?
what u need help with @@kahumaisaac7699
I would genuinely rather walk on burning coal than code on mobile, no offense
Me it has failed
what about the random sum?
Thanks
Lol, std::cout instead of using namespace std😅
It's not funny. Both are correct.
@@toby9999 For a beginner programmer, yes, but in real projects, using namespace std can consume memory.
@@Merovingien514consume memory? I don't think so.
@@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.
bro 1 error is generating
what error
Syntax error
I was always doing cout no. 1; And then repeat with no. 2 but i see that i can just do cin >> a >> b;
But you can make it with "switch" and "case" or also "if" and "else"
Isnt that Python?
It would have been better if you wrote: cout
Nyc kia programming hwy apki well-done
it would be better to write cout
@@RaoRawal786 kyun yaar isme galat kya hai? main abhi bhi sikh raha hun class 8 mein hu mein
@@user-zx5xx4qu1h yeah that can be done either
can you make a video about x, and y
Yes we can by using pointers 👌🏻
twenny one
What name of the app
C++ bruh 😎😂😂😂😅😅
What apps do u use?
Dont knowi
Ok
Bro substraction
💀
👍
How the battery Percentage increases while the program is runned 😂
Bro in which app?
C++
@@savitabhople2774app?not
What are u doing here😂😂
No but which version
I want to install but I can't this exact same
jse c program turbo c or bnte h usi trha c++ kha bnte h
C++ code b Turbo per run ho jata hai but try Dev C++, it is much better than Turbo.
Ye kon sa app h bhai ?
C++ coding❤
@@baisahmad3343 thanks 👍
vs code hi micro soft ka free
Replit use karo
Online c++ compile
11
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++.
Says who? You?
Why? xD
Using namespace std is fine for such simple programs. Multiple declarations separated by comma is also fine, it's valid syntax.
very hard algorithm
its the easiest one
Hi
Wrong this code 😢
Error
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; }
Fun to code