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.
Anonymous
Anonymous
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
> 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.
Thanks for your clarification,
Shivani
but we were talking about c,c++ resources not python
Shivani
my bad
Anonymous
oh
Shivani
yeah, the person who actually asked the question was talking about C, C++ resources
Anonymous
.
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.
Captain
Anonymous
Watup
Suparna
What's the error
It's says "a function defination is not allowed here because { token
Captain
Anonymous
Can anybody tell me, why can't we pass 2d array like 1d array to a function?
Official hooligan of Pius XII
like this:
void foo(int **bar);
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
Anonymous
Anonymous
klimi
there is and answer
Anonymous
But i have to pay money
Anonymous
To get answer
klimi
Anonymous
If you able to solve then please tell me
klimi
that's what you have sent
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?
Nils
Anonymous
Which I am :-(
Why (x)*2 - 1?
Why not just (x). It will fail when x is zero
Nils
Nils
Some will actually accept zero-sized index
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
Suka
Anshul
klimi
you should have asked here...
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++?
Nils
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
Anshul
Anshul
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?
artemetra 🇺🇦
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
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)?