Anonymous
I am a student of software engineering. Anyone have small projects for me?
Shivani
I have read Sumita Arora's book to learn C++ and it's really a nice book to start with if you want to learn.
Shivani
don't recommend bad books
I'm sorry if you find this book bad, you must have read this thoroughly and then decided it as "bad". I have followed Sumita's Arora book for 2 years to learn C++ and clear my concepts from it. I really want to discuss with you why you think it's a bad book. And if you find there are other "good" sources to learn C, C++ then please feel free to mention.
Anonymous
I'm sorry if you find this book bad, you must have read this thoroughly and then decided it as "bad". I have followed Sumita's Arora book for 2 years to learn C++ and clear my concepts from it. I really want to discuss with you why you think it's a bad book. And if you find there are other "good" sources to learn C, C++ then please feel free to mention.
> bad book how many of these terms look familiar to you from your reading of Sumita Arora's book - move semantics, RAII, iterator, smart pointer, type_traits, static_cast, dynamic_cast, auto, range-based for loop > good python book check the python group in telegram, they should have a pinned message with links to references (just like this group). you can also try jetbrains academy. they offer 2 months of free trial which should be enough time if utilised properly.
Shivani
but we were talking about c,c++ resources not python
Anonymous
but we were talking about c,c++ resources not python
? "you find there are other "good" sources to learn python then please feel free to mention."
Shivani
my bad
Anonymous
oh
Shivani
yeah, the person who actually asked the question was talking about C, C++ resources
Anonymous
.
Anonymous
I'm sorry if you find this book bad, you must have read this thoroughly and then decided it as "bad". I have followed Sumita's Arora book for 2 years to learn C++ and clear my concepts from it. I really want to discuss with you why you think it's a bad book. And if you find there are other "good" sources to learn C, C++ then please feel free to mention.
just to be clear—while these are good markers to check for bad C++ books, the job is a bit more involved. an older book like Andrei Alexandrescu's Modern C++ design might not cover some of the newer topics, but it might still be a gem. However, it is completely unacceptable for "introductory" books written after 2011 to not cover these topics. some real indicators (non-exhaustive) of bad C++ books regardless of age - uses void main(). doesn't warn about memory safety issues related to new and delete, undefined behaviour, or the million other ways you can shoot yourself in the foot. has expressions like i++ + i + ++i. uses using namespace std without talking about the associated problems. even without reading Sumita Arora's book, i can guarantee that it hits at least some of these.
Anonymous
then again, by the time you read Modern C++ Design, you will have enough maturity to tune out the out-of-date parts. Only advanced books get the good book pass despite being old.
Suparna
#include<iostream> using namespace std; int main() { int n,i; int arr[i]; cout<<"enter the size of the array:"<<'\n'; cin>>n; cout<<"enter the elements:"<<'\n'; for(i=0;i<n;i++) cin>>arr[i]; struct pair { int min,max; }; struct pair getminmax(int arr[], int n) { struct pair minmax; int i; if(n==1) { minmax.min=arr[0]; minmax.max=arr[0]; return minmax; } if(arr[0]>arr[1]) { minmax.min=arr[1]; minmax.max=arr[0]; } else { minmax.min=arr[0]; minamx.max=arr[1]; } for(i=2;i<n;i++) { if(arr[i]>minmax.max) minmax.max=arr[i]; else(arr[i]<minmax.min) minmax.min=arr[i]; } return minmax; cout<<"minimum element is:"<<minmax.min<<'\n'; cout<<"maximum element is"<<maximum.max<<'\n'; return 0; } } Can anyone help me ?? It's shows error in line no 20.
Anonymous
Watup
Suparna
What's the error
It's says "a function defination is not allowed here because { token
Captain
It's says "a function defination is not allowed here because { token
Define struct and function above main, and then call them in main.
Anonymous
Can anybody tell me, why can't we pass 2d array like 1d array to a function?
Official hooligan of Pius XII
Can anybody tell me, why can't we pass 2d array like 1d array to a function?
you can return a pointer to 2D array and you can pass it as an argument with ** pointer
Official hooligan of Pius XII
like this: void foo(int **bar);
Anonymous
It's says "a function defination is not allowed here because { token
use a code-formatter like clang-format and a sensible IDE that automatically formats your code on save. these types of errors will vanish as soon as you get to see your code properly.
Anonymous
Can anybody tell me, why can't we pass 2d array like 1d array to a function?
1) types must be known at compile-time 2) arrays decay into pointers when used in an expression e.g. an array with the type int[2][3] decays into int (*)[3]. function signatures like void foo(int arr[][3]); or void foo(int (*arr)[3]); definitely work. but you might want a function that works with arbitrary "row" and "column" sizes, in which case you either 1) need to use int *arr and do the calculations manually i.e. *(arr + row * ROW_SIZE + col) or 2) need to use lookup tables (int ** as explained above by skelly37)
Anonymous
note that (2) isn't really a multidimensional array. the "row"s of such an "array" are probably scattered across memory and the main array just contain pointers to those rows.
Anonymous
https://www.chegg.com/homework-help/questions-and-answers/please-give-optimized-code-o-n-cpp-java-language-code-according-function-prototype-please--q84725369
klimi
Please Send me code of this question
the code is on the website... i don't understand why you would bother this group with this
klimi
there is and answer
Anonymous
But i have to pay money
Anonymous
To get answer
klimi
To get answer
yes exactly
Anonymous
If you able to solve then please tell me
klimi
that's what you have sent
klimi
If you able to solve then please tell me
no at all... just bad photos of screen with assigment won't make me solve something just like that
Anonymous
Wait I'm sending u
Anonymous
Can u text me in personal
klimi
no, i refuse
Anonymous
Here I'm not able to send pic
klimi
Yes exactly, because it is against rules
Nils
#define COMPILE_TIME_ASSERT(name, x) \ typedef int compile_time_assert_##name[(x) * 2 - 1] Is this a good way to do compile time assertions in C?
Anonymous
#define COMPILE_TIME_ASSERT(name, x) \ typedef int compile_time_assert_##name[(x) * 2 - 1] Is this a good way to do compile time assertions in C?
Why do you want to reinvent the wheel? C11 already has a _Static_assert that can be used for compile time assertions unless you are working on C99 code
Anonymous
Which I am :-(
Why (x)*2 - 1? Why not just (x). It will fail when x is zero
Nils
Why (x)*2 - 1? Why not just (x). It will fail when x is zero
because some compilers don't behave like that
Nils
Some will actually accept zero-sized index
Anonymous
because some compilers don't behave like that
All standard compliant compilers should fail an attempt to define a zero sized array unless you are dynamically allocating it
Abhishek
Yes
Anonymous
#include<stdio.h> int main() { float n,num; int i,sum=0,c=0; printf("Enter the input number"); scanf("%f",&n); for(i=1;i<=n;i++) { scanf("%f",&num); if(num>0) { c++; sum=sum+i; } } printf("%d values are positive\n",c); float avg = sum / c; printf("%.1f",avg); return 0; }
Anonymous
Why avg 3.0 is coming. It should be 7.4
klimi
you should have asked here...
Anonymous
I want to know when are these terms used. I am learning data structures and algorithms using c++ and before that I learnt c++ basics. But till now I never needed these terms.
for everything other than dynamic_cast - literally everywhere dynamic_cast - some inheritance related situations. https://en.cppreference.com/w/cpp/language/dynamic_cast#Example
Anonymous
I want to know when are these terms used. I am learning data structures and algorithms using c++ and before that I learnt c++ basics. But till now I never needed these terms.
> I learnt c++ basics those terms are the basics. iterator, smart pointer, static_cast, auto, range-based for loop are basics for any C++ programmer move semantics, RAII are basics for anyone writing C++ classes type_traits is basic for anyone writing template metaprogramming code
Neeraj
Hi i am doing a problem and an stuck. .Want to find largest subarray with largest sum. So what am i doing is- running a loop on the array and cou ting the sum of elements by doing sum+=nums[i] and at the same time storing the sum of each vector in the new array. So that i can compare it later. But what i don't have idea is. How will i get the largest substring.
Dr
what i would do is, create window of size of subarray i want and calculate aggregate of elements of that window! And whenever max sum is found, i'll store that initial index
Hari Putter
Can anyone suggest me college project using c++?
blify
👋
klimi
#ot
Anshul
> I learnt c++ basics those terms are the basics. iterator, smart pointer, static_cast, auto, range-based for loop are basics for any C++ programmer move semantics, RAII are basics for anyone writing C++ classes type_traits is basic for anyone writing template metaprogramming code
No what I actually mean is that while learning dsa for interviews I didn't need these terms(like static_cast, move semantics, raii, range based for loops,smart pointer, type_traits... etc) yet and none of the video lectures that I followed talked about these terms That's why I want to know where are they used
Pavel
No what I actually mean is that while learning dsa for interviews I didn't need these terms(like static_cast, move semantics, raii, range based for loops,smart pointer, type_traits... etc) yet and none of the video lectures that I followed talked about these terms That's why I want to know where are they used
Not sure what you mean where, they used writing modern C++ code. I mean not every app uses all of these (e.g. smart pointers in embedded software or with other places where "orthodox C++" used), but they are kind of essential parts of modern C++ and it usually helpful to know what they are at least and why they are exist.
Anshul
Not sure what you mean where, they used writing modern C++ code. I mean not every app uses all of these (e.g. smart pointers in embedded software or with other places where "orthodox C++" used), but they are kind of essential parts of modern C++ and it usually helpful to know what they are at least and why they are exist.
My question basically is when you learnt c++ for the very first time did you learnt them or you learnt them after getting placed into some company. Because for me the case is till now I haven't come across these terms. Btw what do you do? Are you a student or a working professional
Anshul
By "them" I mean the terms we're referring
Pavel
My question basically is when you learnt c++ for the very first time did you learnt them or you learnt them after getting placed into some company. Because for me the case is till now I haven't come across these terms. Btw what do you do? Are you a student or a working professional
I've learned part of them when working on my hobby projects and part of them after I've got my first job (auto, move semantics and range-based for loop, because they were rather new features of the language back then). I would say, move semantics is advanced stuff, it's like you read about it, you think you understand it, then you read more and practice more, understand your previous mistakes, do new mistakes, understand them, and then at some point start using it efficiently and do less mistakes. I don't think it's required somewhere for a junior position to really understand it.
Anshul
Ok thanks
Pavel
Ok thanks
If you want an easier journey to all that stuff, you can read "Effective C++", "More Effective C++" and "Modern Effective C++" from Scott Meyers, they cover a lot of common mistakes and common knowledge things about C++. It's a bit more advanced reading, so you may want to skip some paragraphs when reading to return to them later
Anonymous
Hi Is there anyone who's good with php?
artemetra 🇺🇦
hi, i wrote this line of code, but i'm not sure how to refactor it to make it more readable and/or concise if (((curveType == CurveType::ENVELOPE || curveType == CurveType::LFO) && points.size() >= 1) || (curveType == CurveType::GRAPH && points.size() >= 2)) { is there a way to do the same boolean operations but a bit nicer to read?
T
/rules
Y
Hi
Y
there is someone who programs on C#?
T
I am unable to make this code work with ( and ) brackets in converting infix to postfix expression ,the program returns a garbage value when tried to do so. I tried all sorts of ways to make this program work but failed so trying to find the solution . https://pastebin.com/FWBxYUNF
Pavel
there is someone who programs on C#?
Hi, why is it related to C/C++? Also, have you read this? https://bit.ly/3jNHlra
artemetra 🇺🇦
Curve.h: class Curve { ... CurveType m_type = CurveType::GRAPH; std::vector<Point> m_points = {}; ... Curve.cpp: ... m_type = curveType; m_points = points; ... why am i getting a "variable Curve::m_type" is uninitialized warning (visual studio)?