RØB
what is it doing "improperly"?
Wt is wrong with my program
RØB
klimi
you are saying that your program is not working properly, what is it doing differently that you want?
klimi
Plz run tht program & see
are you seriously unable to answer such easy question?
RØB
If with semicolon?
Thx Now program is working properly😊
Nana
Pls I want to do bubble sort with my class program I do get an error when I run the code
Nana
#include <iostream> #include <iomanip> #include <ctime> #include <cstdlib> using namespace std; class Rainfall { private: double rain_amount; double total_rainfall; public: void setRainfall(double rain) { rain_amount = rain; } int getRainfall() { return rain_amount; } void getTotalRainfall(double total_rain) { total_rainfall = total_rain; } int totalRain() const { return total_rainfall; } int getAverageRainfall() const { return total_rainfall / 12; } }; void intro(); int main() { intro(); return 0; } void intro() { cout<<"\t\tThis is a rainfall program in C++\n"; cout<<"\t\t--------------------------------------\n"; cout<<endl; int month = 12; string month_names[] = {"Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"}; int amount; int total; int lowest; int max = 200, min = 20; unsigned seed = time(0); srand(seed); Rainfall rain[month]; for(int count = 0; count < month; count++) { amount = (rand()%(max - min+1))+min; rain[count].setRainfall(amount); total += amount; rain[0].getTotalRainfall(total); } cout<<endl; cout<<"Here are the rainfall values entered by the user\n"; cout<<"Month Names\t\tRainfall Amount\n"; cout<<"--------------------------------------------------\n"; cout<<fixed<<setprecision(2); for(int count = 0; count < month; count++ ) { cout<<month_names[count]<<"\t\t\t"<<rain[count].getRainfall()<<endl; } cout<<endl; cout<<"The total Rainfall amount is: "<<rain[0].totalRain()<<endl; cout<<"The average rainfall for the months is: "<<rain[0].getAverageRainfall()<<endl; bool swap; int temp; do { swap = false; for(int count = 0; count < month-1; count++) { if(rain[count].getRainfall() > rain[count + 1].getRainfall()) { temp = rain[count].getRainfall(); rain[count].getRainfall() = rain[count + 1].getRainfall(); rain[count + 1].getRainfall() = temp; } } }while(swap); for(int count = 0; count < month; count++) { lowest = rain[0].getRainfall(); if(rain[count].getRainfall() < lowest) lowest = rain[count].getRainfall(); } cout<<endl; cout<<"The lowest rainfall amount is: "<<lowest<<endl; }
Nana
The error is at this part
Nana
do { swap = false; for(int count = 0; count < month-1; count++) { if(rain[count].getRainfall() > rain[count + 1].getRainfall()) { temp = rain[count].getRainfall(); rain[count].getRainfall() = rain[count + 1].getRainfall(); rain[count + 1].getRainfall() = temp; } } }while(swap);
Nana
Pls I need your assistance
klimi
for swapping things cannot you just use std::swap?
klimi
just curious if you were to trying to write it without it
Nana
just curious if you were to trying to write it without it
I wanted to try if I could swap values contained in classes
Nana
with normal arrays, the above works
Klaus
Where to get project details
Klaus
Phone book
klimi
what?
Pavel
Where to get project details
From where you've got the project
Klaus
I wanted to do a mini project
Klaus
For my college
Klaus
How to start with my team someone guide me
Lokesh
Best flatform to learn c++
Lokesh
And java
Ludovic 'Archivist'
today still no std::htonll
You have c++23 bswap and std::endian, or you implement it with shifts and pray that a non Microsoft compiler will optimize it (they generally do, ms ones don't)
Ludovic 'Archivist'
that’s why rust performs far better in terms of standard library
Sorry, but from the inside rust standard lib manages to be more of an horror story than stdlibc++
Ludovic 'Archivist'
And even worse than libphobos which was also quite traumatic
Ludovic 'Archivist'
The most problematic parts of C++ are relics: the iostream, std::allocator, locale facets, and std::unordered_map
Ludovic 'Archivist'
The rest delivers what it promises (except whatever passes for an implementation of make_heap on libstdc++ but really, did you ever use make_heap at work?)
paper
Best flatform to learn c++
https://adriann.github.io/programming_problems.html Solve these and you're pretty much done with the basics
M
Hi guys, I’m studying MSc International Management but I’ve always been interested in coding. So some days ago I started with C, I hope to find useful resources and nice people here :)
Engineer
https://www.efinancialcareers.co.uk/news/2022/04/c-developer-pay-finance
M
https://www.efinancialcareers.co.uk/news/2022/04/c-developer-pay-finance
thanks! I’m more inclined to work as a standard PE guy
Engineer
I still remember when I was confused when reading the following for the first time 🤣 : In object-oriented and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created. This is in contrast to a mutable object (changeable object), which can be modified after it is created.
Rajeev
#include <iostream> using namespace std; int main() { int a[3]; a[0]=1; a[1]=2; a[2]=3; int x[3]; x=a; return 0; } Why error: invalid array assignment?
Rajeev
You mean 'a' stores address of the array. And we can't store an array's address to x having type-int!!
布丁
Can't understand lvalve??
sorry typo... should be lvalue, left value
Rajeev
When we have to use size function of vector. We do vector_name.size() Then why, we don't do same for iterator? Example: vector_name.iterator is wrong. But, vector<int> :: iterator it = v.begin; is right???
Rajeev
Please clear my confusion between fullstop and double colon . and ::
Ludovic 'Archivist'
What kind of horror story?
code that works "in theory" but doesn't take into account IEEE754 properties, code that uses generic but very suboptimal algorithms instead of using type introspection and other things like that
Emmanuel
#include <iostream> using namespace std; int main() { int a[3]; a[0]=1; a[1]=2; a[2]=3; int x[3]; x=a; return 0; } Why error: invalid array assignment?
The statement "x=a" is assigning the memory address of a to x which doesn't make sense, hence leading to compilation issues because two different arrays are referencing the same address in memory.
\Device\NUL
Silly question, why most people hate C++ STL ?
M
Hi, Is “Learn C the hard way” valid for a beginner? (after I learned the basics and pointers)
布丁
Silly question, why most people hate C++ STL ?
much more complicated than it seems, but lacks many features (or added in very recent standards)
Евгений
Hi, Is “Learn C the hard way” valid for a beginner? (after I learned the basics and pointers)
C language will give more then you can get from other high level languages. After C language you'll understand that Java, Python or even C# are garbage. Even if they have a lot of sugar syntax. C language will allow you to learn much more and more better way how it's really works. Other languages are hiding the most tasty parts of a language, that's why Java or Python programmers can't do real programming. They can only use a language like a Lego game. Java was written in C language, Python was also written in C language. But you can't make your own powerful language using Python or even Java. So now I hope you understand what C language is. It's a power))
Danya🔥
I've not seen such a narrow-minded opinion in years
Danya🔥
I hope you grow up sometime
Евгений
I hope you grow up sometime
Maybe you can give a more wide explanation:)
Danya🔥
Maybe you can give a more wide explanation:)
The purpose of programming is to get things done. Not to sink in "tasty parts of a language". A programming language is not a goal or an absolute, it's just a tool.
shuzuya
I hope you grow up sometime
Please telling how am sure his trying it good to enlighten people you know
shuzuya
So, your statements that "Java or Python programmers can't do real programming" - just silly.
Actually he needs to expound on what real vs fake or whatever the other is means
Danya🔥
Actually he needs to expound on what real vs fake or whatever the other is means
There is no "real" or "fake" programming. The world is not black and white. Any statements like "They can't do real programming, but we can" are so childish
shuzuya
🙄🙄
Евгений
There is no "real" or "fake" programming. The world is not black and white. Any statements like "They can't do real programming, but we can" are so childish
Maybe you should search who wrote all libraries for you to use them in Python or Java.)) I think you never even worked in a big companies. Just making HTML sites
Danya🔥
Maybe you should search who wrote all libraries for you to use them in Python or Java.)) I think you never even worked in a big companies. Just making HTML sites
> Maybe you should search who wrote all libraries for you to use them in Python or Java So, not all libraries available to Python are written in Python - so what? :)
Danya🔥
So, anyways, @AndelieYoujin, I'd suggest you not to embarrass yourself and grow up already
M
Okay but my question still is unsolved ahahah Is “Learn C the hard way” valid for a beginner? (after I learned the basics and pointers)