Anonymous
https://www.quora.com/How-do-I-find-kth-number-whose-cube-ends-in-888?share=1 The n-th lucky number will be 250*(n-1)+192
Follow his explanation to understand why the numbers are in this format. I learnt something as well. So, thanks for this question.
klimi
klimi
I'm not talking to you tho :/
Anonymous
not ban, just a warn maybe. also, i am not an admin, so i can only report. it is not my responsibility to warn or ban. if you really want a list —————————————————- Rule 1 - angry "If you guys can help me then reply me orelse please stay away" rule 2 rule 3 - "Exam" rule 7 - did all this just after joining rule 14 rule 1 implied i assume (admin discretion needed) - passive agressive, desperate "If you are a intellegent come on i will give a problem solve it then i will accept you" "@Tazmikar heyy please msg me personally" "Heyy msg me sister" also, reporting me for no reason?
Wahid Ahmad Mohammadi
Hi
Wahid Ahmad Mohammadi
How can we concotatnte in c
Anonymous
How can we concotatnte in c
U can google it u know... instead of typing that here
Anonymous
How can we concotatnte in c
+ operator with strings
Anonymous
+ operator with strings
No you cant. You cant add 2 char* pointers
Anonymous
No you cant. You cant add 2 char* pointers
Oh yes i think +operator is java thing
Anonymous
How can we concotatnte in c
Create memory large enough to hold both the strings and a null character. Use strncat or memcpy following that. Btw it is "concatenate".
NAM3L3SS
Hey fam. Still putting my head around array bounds checking If y'all don't mind what are its disadvantages?
Anonymous
Hey fam. Still putting my head around array bounds checking If y'all don't mind what are its disadvantages?
Bounds checking requires the compiler to add extra information to your executable. This could be information like storing the length of the array along with the array during both stack and heap allocations. Also code needs to be added to check the bounds are not exceeded during each array access. Sometimes this is not straightforward with pointers coming into picture which just adds adds more gruesome runtime checks to the mix. If bounds are exceeded then either an exception must be thrown (an expensive operation by itself) or the program must be aborted. All of these impose significant run time impact and were considered not acceptable for a systems programming language when C and C++ were designed. So it is left to the programmers instead. Having said that, Rust shows us a way to design a system programming language which does bounds checking with very low cost runtime overhead with its fat pointers. But Rust does this because of the way it was designed. Unlike C++, it wasnt designed to be a better C but instead it evolved a new programming paradigm itself. C and C++ unfortunately cant do the same.
Anonymous
Hi
Thomas shelby
Can anyone tell why this """printf("%d xp",*xp); printf("%d yp",*yp);""" doesn't print anything???
Thomas shelby
#include <stdio.h> void swap(int* xp, int* yp) { if (xp == yp) // Check if the two addresses are same return; *xp = *xp + *yp; printf("%d xp",xp); *yp = *xp - *yp; printf("%d yp",yp); *xp = *xp - *yp; } int main() { int x = 10; swap(&x, &x); printf("After swap(&x, &x): x = %d", x); return 0; } Can anyone tell why this """printf("%d xp",*xp); printf("%d yp",*yp);""" doesn't print anything???
Anonymous
It's a little bit confusing
xp is initialized with &x and yp is also initialized with &x. So xp==yp is true. If this is the case you run the statement return which just returns from the function. Code following that will not execute. I expected more from a Peaky Blinder.
Thomas shelby
Thank you so much
R
//Write a C program to find roots of a quadratic equation using switch case. (use if else) #include <stdio.h> #include <math.h> int main() { int a,b,c,d; float root1,root2; printf("Input the value of a,b & c : "); scanf("%d%d%d",&a,&b,&c); d=b*b-4*a*c; if(d==0) { printf("Both roots are equal.\n"); root1=-b/(2.0*a); root2=root1; printf("First Root Root1= %f\n",root1); printf("Second Root Root2= %f\n",root2); } else if(d>0) { printf("Both roots are real and diff-2\n"); root1=(-b+sqrt(d))/(2*a); root2=(-b-sqrt(d))/(2*a); printf("First Root Root1= %f\n",root1); printf("Second Root root2= %f\n",root2); } else printf("Root are imeainary"); return 0; }
Anonymous
Who is American here?
Anonymous
Hi
Anonymous
Hi
Anonymous
Hi
Ravi
Helo
Anonymous
Thanks for allowing me into your group
Anonymous
Hi
Talula
Hi
/report bot
Anonymous
/report
Anonymous
Hi everyone on this group am New here hope I'm welcome?
Anonymous
Can someone tell me more about this program?
Talula
Can someone tell me more about this program?
I think you're in a wrong group if you want to learn more about programming... this is specific to C/C++ problems.
Roxifλsz 🇱🇹
Hi
/ban hi
Anonymous
#Puzzle #include <iostream> using namespace std; class Test{ public: Test() try : c{nullptr} { //constructor body throw 0; } catch(...){ cout<<"Exception"; } private: char* c; }; int main(){ Test obj; } Why does this code throw an exception in main when the exception has already been caught earlier and the code is not explicitly rethrowing the exception?
#Solution The code shown in this puzzle would be a bit weird if you have not heard of function-try-block. It is used to associate a try-catch block with the entire function. If used with a constructor, it covers the member initializer list and base class constructor calls as well. So if an exception is thrown during member initialization or from a base class constructor, it can be caught here. As to why this code throws an exception again even after it is handled already, read Herb Sutter's excellent explanation here: http://www.gotw.ca/gotw/066.htm
Anonymous
Thank you
Anonymous
Is VSCode muh better for C
Dhahamsa
Hi, can anyone teach me python/java/html? pls for my studies. Sorry if it's something not related to the group.
Anonymous
එල
Dhahamsa
Hmm😊
Anonymous
group ekak thiyenae
Anonymous
Join wenna onenam
Dhahamsa
group ekak thiyenae
programming wltd?
Anonymous
group ekak thiyenae
Why dont you love birds take your conversation to a private message? This group entertains English only. Not Sinhalese.
Anonymous
අනේ හා
Anonymous
Is VSCode muh better for C
There are many IDEs out there. Try them out and decide which one you like. CLion is another one. People use Eclipse as well.
Anonymous
හ්ම්ම්
Dhahamsa
Google it!
Alright
꧁༒𝐀𝐡𝐦𝐚𝐝༒꧂
I have presentation about robotic. I need references for components in Robots and list of languages use in Robotic. Please help me and recommend references
Amit
Can anyone help me to understand how local variables are returned in C++
Amit
int* fun() { int x = 20; int* ptr = &x; return ptr; } // Driver Code int main() { int* arr = fun(); cout << *arr; return 0; }
Amit
Here in this code.... isn't ptr variable's scope is limited to function only....and isn't memory containing 'x' variable will be deleted once fun() get returned(or pop from stack).....how
Amit
Can we still Able to access value at 'x' variable...that's is 20
Ravi
that is true, local variable ptr is only up to that fun only,
Ravi
but, as we have used pointer, then the address is saved of the variable x
Ravi
so we have access to the data which is stored in X
Ravi
we can try by manipulating the pointer data also, it will result in changed value of X
mito
#include <iostream> int main() { std::cout<<5.00975542f<<"\n"; std::cout<<5.00975542; return 0; } Both outputs only 6 significant number. But double has more precision right?
Anonymous
#include <iostream> int main() { std::cout<<5.00975542f<<"\n"; std::cout<<5.00975542; return 0; } Both outputs only 6 significant number. But double has more precision right?
Precision doesnt mean the number of digits displayed. Precision defines that the maximum difference between a floating point representation of a number and the actual number wont be greater than 10^-6 for floats and 10^-10 for doubles. For float the precision is at minimum 6 and for double the precision is at the minimum 10. Expressed as a percentage it is 10^-4% for float and 10^-8% for double.
Anonymous
but when precision increases the significant figures on the decimal side also increases right ?
The precision here represents the accuracy. It also depends on the number you are trying to represent. Just because the mantissa can store more bits in a double does not mean it has to display more digits. It could be the case that the number you are trying to store could be accurately represented in both a float and a double with the same number of digits. So there are a lot of variables here.
Anonymous
int* fun() { int x = 20; int* ptr = &x; return ptr; } // Driver Code int main() { int* arr = fun(); cout << *arr; return 0; }
This is Undefined Behavior. What happens is that the variable is still on the stack. There is no concept of popping on stack frames like you are used to in the stack data structure. The stack pointer is just moved to point into the earlier function's stack frame. So the contents of the stack where x was stored might still be there which is what you are seeing in this code. This is UB but.
z
int* fun() { int x = 20; int* ptr = &x; return ptr; } // Driver Code int main() { int* arr = fun(); cout << *arr; return 0; }
Yes, this is undefined behavior. Local variable lifetime ends when the function returns. Except for static local variable. You are basically just reading random data off the stack.