olli
I don't think that float is an issue in this case
I do :P #include <cmath> #include <cstdio> int main() { int Base = 500'000; printf("%f\n", Base * powf(1 + 0.035, 10)); printf("%f\n", Base * pow(1 + 0.035, 10)); return 0; } Running yields: Program returned: 0 705299.125000 705299.380311 https://godbolt.org/z/Wd98dh
Vlad
It's like saying that if you can't hit target with shotgun — use double barreled.
Vlad
Sure it'll help
olli
He's off by like 500k
fair. He printed the total amount of money but expected to print the interest only I guess. I would have thought we wanted to print the total sum of money, where using double would yield the correct result.
olli
It should be 205299.38
use double and subtract your initial value if you only want to have the interest gained or subtract 1 from the pow result
Hrithik.41
Send me the code
olli
Send me the code
how about doing it yourself?
Hrithik.41
If u able
Hrithik.41
But if I show u the result
Hrithik.41
Bot will warn again😅
Vlad
Send me the code
You're a big boi we won't spoon feed you
olli
Bot will warn again😅
https://paste.ubuntu.com/ Use this, paste the code there and share the link e.g. https://paste.ubuntu.com/p/9Z2SskTvRS/
Anonymous
/report screen photo + outdated compiler
Using old ide give ban 🤣🤣🤣🤣
olli
Using old ide give ban 🤣🤣🤣🤣
well, there is no reason to use this, we had this discussion so many times already.
dj
how to take <string> type as a function argument is it like this: #include<iostream> #include<string> void f(string a){cout<<a<<endl;}
Vlad
You don't want to copy them around
dj
?
dj
is nt it better to pass ?
Jasur Fozilov 🐳
Is geekforgeeks.org better or better for learning algorithms and data structures?
Vlad
?
foo(string a); copies an entire string that you pass into it
Vlad
And allocates as well
dj
I see passing vector like this
Vlad
It also copies an entire vector
dj
It also copies an entire vector
so whats the way to pass ?
Vlad
so whats the way to pass ?
No. Pass containers by reference.
Vlad
If your function doesn't write into container, pass as const ref
dj
as a pointer ? foo(string *a) ?
Vlad
as a pointer ? foo(string *a) ?
foo(const string& a)
dj
function write into container
Anonymous
Using old ide give ban 🤣🤣🤣🤣
Don’t talk to me ever again
Vlad
function write into container
Your example was just an output
dj
Your example was just an output
yes but I was just asking to know how to write argument
Vlad
yes but I was just asking to know how to write argument
void foo(vector<float>& pies) { while(true) pies.push_back(3.14f); }
dj
aah ok :) oh with &
dj
I saw it, thanyou :)
dj
forgot ref, pardon
I can do like this for string too right foo(string &a)
dj
Ok thankyou :)
Anonymous
For anything actually
How much experience in c you have just for knowledge
Anonymous
Hey! Do u know any website or sth for all solving problems of flowchart?
No.7 Addict 👽
Manav
Is geekforgeeks.org better or better for learning algorithms and data structures?
No, there's a course on algorithms by mitopencourseware on youtube. i remeber it was from 2015ish or so. There haven't been any significant breakthroughs in DSA to make a 5 year old course any less relevant
Manav
Thanks
if you can't find it, enroll in any DSA course from sites like coursera, edx.org
Manav
sites like geekforgeeks, w3schools are riddled with mistakes, bad programming habits, etc. Don't use them for anything but quick referencing
Nameful
w3schools' recent stuff is okay
Nameful
their older things that haven't been updated ... less so
Nameful
and geeksforgeeks is just generally bad
Manav
their older things that haven't been updated ... less so
it's not about being updated, the quality of the articles on these websites depend on the authors who write them. there's hardly anyone who checks these. At least people on stackoverflow berate people who write shit as answers.
Manav
lets be honest here, a significant number of the poeple who write on these sites are students themselves.
Manav
The best use of these sites is to quickly check some api usage, etc. Not learn stuff
Hadaward 'Solly'
also applies to the questions
Anonymous
ok ok you can download it from play store without clicking on my link
Anonymous
😑
Anonymous
happy
Accel
I found learncpp better for beginner lvl
Anonymous
I'm new to cpp, can anyone explain me solution from this link.. https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/discuss/458303/C%2B%2B-O(n)
️Yunus
/get cbook
Anonymous
/get
Cbcee
1
Anonymous
guyz nesquick question
Anonymous
I have a type called toroide which is vector<vector<bool>> and I want to declare a toroide of a certain size (certain size of the rows and collums) how do i do that? 4 example in a vector we just do vector v (size); i guess it's toroide t (size_rows)(size_columns); but it doesn't work :(
Alex
https://www.techiedelight.com/vector-of-vector-cpp/
Anonymous
thanks gotta learn how to google my own sry :(
Anonymous
otherwise you'd get duplicates
SHAISTA
Plz recommend c++ book or share pdf in this group
Ludovic 'Archivist'
net
BrainFuck compiler in c++ template metaprogramming https://www.reddit.com/r/cpp/comments/jnz5p1/brainfuck_compiler_in_c_template_metaprogramming/?utm_medium=android_app&utm_source=share
S
/get cbook