z
I still don't understand 😅.
The order of local variables on the stack is undefined. It's up to compiler how it will place it.
z
Different compiler may yield different result, because of UB.
z
Even at different optimization level, UB may yield different result as well.
mito
The order of local variables on the stack is undefined. It's up to compiler how it will place it.
So , Evey time I loop , the stack order gets changed , is that right? Because the order of local variables on the stack is undefined?
z
So , Evey time I loop , the stack order gets changed , is that right? Because the order of local variables on the stack is undefined?
No, the loop doesn't change the order. It's fixed at compile time. If you compile it with different optimization level, it can yield different result. Or with different compiler as well.
z
It may not even be on the stack if you use higher optimization level. The compiler may elide unused variables.
mito
Exactly.
ok, thankyou, I'll look into fputs() further to know what it exactly does...
Anonymous
Am a learner how can you help me
Anonymous
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s)) #define F_OR1(e) F_OR(i, 0, e, 1) #define F_OR2(i, e) F_OR(i, 0, e, 1) #define F_OR3(i, b, e) F_OR(i, b, e, 1) #define F_OR4(i, b, e, s) F_OR(i, b, e, s) #define GET5(a, b, c, d, e, ...) e #define F_ORC(...) GET5(VA_ARGS, F_OR4, F_OR3, F_OR2, F_OR1) #define FOR(...) F_ORC(VA_ARGS)(VA_ARGS) can anyone explain wat does FOR(...) and FORC() and GET5() expands to
Anonymous
On a machine where sizeof(float) is 4 and sizeof(double) is 8, float f = 2.5 uses 8 bytes of memory, since floating point literals are of type double by default. float f = 2.5f uses 4 bytes, since the suffix f tells the compiler to treat the constant 2.5 as a float. Is my understanding correct? Also, how does the conversion from double to float work? Does it need to allocate separate memory for the converted float?
Anonymous
No. float f = 2.5 uses 4 bytes 2.5 is just truncated to single precision
I read that not adding the suffix 'f' to a float constant is "wasteful" since the compiler stores it as a double. What kind of waste are we talking about here then?
Giuseppe
Import gc Del list Del myarray gc.collect() It is a way to free the memory in Python? Isn't?
Mar!o
I read that not adding the suffix 'f' to a float constant is "wasteful" since the compiler stores it as a double. What kind of waste are we talking about here then?
Well if you say float x = 0.0 it's not needed, but in many situations it is. Just always write .f when ur dealing with floats
Mar!o
I read that not adding the suffix 'f' to a float constant is "wasteful" since the compiler stores it as a double. What kind of waste are we talking about here then?
Consider: auto x = 0.0; // double auto y = 0.0F; auto f() { return 3.5F; // float } auto f(float y) { return y * 2.0; // returns double but y is float } 2.5f * 2.0 yields a double too ```
MSP
I need job
Sachin
Any program to find smallest no in array having time complexity less than O(n)
z
Any program to find smallest no in array having time complexity less than O(n)
Yes, just simple loop with if statement should be enough and be O(n).
z
Oh less than O(n), I don't think so.
Sachin
If your array is sorted, you will have O(1).
Koi esi shorting jo O(n) se kam ki ho
Apk
Any program to find smallest no in array having time complexity less than O(n)
I mean you will need to look at all numbers to find the minimum🤔
Sachin
Time complexity
Sachin
Exactly
Any shorting less than oo of n
Apk
Any shorting less than oo of n
I don't know of any sorting that is even O(n)
Apk
So most probably no
Sachin
Apk
Just I wanna know
It's not possible unless you have an already sorted array.
Tunechi
Guys who is able to make a robot to do some task
Dishant
I have recently started learning REGEX but however I am unable to know what is the syntax and functions used in regex . It would be appreciated if anyone can tell me some reliable source to know about this !!
Adarsh
#include<bits/stdc++.h> using namespace std; int maxCircularSum(int arr[],int n) { int res=arr[0]; for(int i=0;i<n;i++) { int curr_max=arr[i]; int curr_sum=arr[i]; for(int j=1;i<n;j++) { int index=(i+j)%2; curr_sum+=arr[index]; curr_max=max(curr_max,curr_sum); } res=max(res,curr_max); } return res; } int main() { int arr[]={5,-2,3,4}; cout<<maxCircularSum(arr,4)<<endl; return 0; }//my this code is not executing idk why......any suggestions?
Adarsh
Does it show any error?
no but not even running
Pavel
Not sure what "not running" mean. Let me check
Pavel
no but not even running
it runs but gets into an infinity loop https://ideone.com/4voxq3 you have a copy-paste error in the second loop, in line 10 should be j<n instead i<n
Someone
Is Relevel hiring by unacademy worth?
Mahdi
Hello book C++ What do you suggest Which you actually exited.
Mahdi
Remembering pv
Anonymous
Can anyone share a pdf or something, to deeply understand the working of C++? Like, linkers, header files, pre processors, in depth. I know stuff but I wanna get more into it.
klimi
If it is legal, then people can share it...
Kartik
#include <iostream> using namespace std; void getdata(int a,float b); void putdata(); class item { public : int mobile,laptop; private : mobile = a; laptop =b; }; void item::getdata(int a,float b) { num=a; cost=b; } void item::putdata () { cout<<"number"<<num<<endl <<"cost"<<cost<<endl; } int main() { obj m; object.item= putdata(); object.item=getdata(int a,float b); return 0; }
Kartik
Pls help me
Kartik
There is a logical error
Kartik
I need this in college assignments
Golden Age Of
Kartik
Sir sorry but I am learning
Golden Age Of
Sir sorry but I am learning
A lot of mistakes, but ok
Kartik
Thanks sir good to hear that
Golden Age Of
Read about constructors and destructors and getters/ setters. Also you should know that class or struct is your personal data type as int, double etc. And you can operate with it any way you need, every time you create the OBJECT of your CLASS, you create a member with certain variables and functions.
Kartik
So by default class is accessible to public
Golden Age Of
So by default class is accessible to public
By default class is private, struct is public
Kartik
Can I show you the
Kartik
Error which i encountered in the mobile ide
Golden Age Of
Are you trolling us here?
Golden Age Of
I'm just messed up a bit?
z
/report
Kartik
Are you trolling us here?
No no sorry vs code
Kartik
I'M using dev cpp and vs code
Kartik
Mobile ide?
Sorry sir I am saying that is in dev cpp
Golden Age Of
Error which i encountered in the mobile ide
I've shown you your mistakes you should try to fix it firstly, dominantly incorrect is main function*
Kartik
Ok sir this will took time if I do it myself and refers to book