klimi
You're welcome
JCV
i don't know why travis on github detect problems with that
JCV
travis error main.cpp:26:10: fatal error: CoreFoundation/CoreFoundation.h: No such file or directory #include <CoreFoundation/CoreFoundation.h>
Dima
maybe you need to link apple libraries
Dima
frameworks*
AFOUDA
Hi everyone. I have an issue with a code that i’m writing. I’m trying to solve a simple linear equation but with the following test case : 999999999x + 999999999 = 1 my code return x=-1.000000 instead of x=-0.999999 Could someone help me fix that ?
AFOUDA
I_Interface
@Neko_cpp :D
Javi
Hi everyone. I have an issue with a code that i’m writing. I’m trying to solve a simple linear equation but with the following test case : 999999999x + 999999999 = 1 my code return x=-1.000000 instead of x=-0.999999 Could someone help me fix that ?
That's more likely rounding error. Better read how numbers are represented by computers. Long story short: you won't solve it without a lot of coding, and probably not even then
Igor🇺🇦
CoreFoundation vs corefoundation
JCV
CoreFoundation vs corefoundation
I will check that but i think that’s the location for headers because on mac everything compile and run fine
AFOUDA
printf("%.10f\n", (double) (c - b) / a );
Thanks @noPV2 it work very well if I want 9 or more digits précision. But what if I want less. Like 6 or 7 for example. The specification of the exercise is to print the answer with 6 digits precision.
JCV
how can i use this LIBS on QT .pro just for mac avoiding windows and linux? LIBS += -framework CoreFoundation
JCV
y use this os2 { LIBS += -framework CoreFoundation {
JCV
and this mac { LIBS += -framework CoreFoundation {
JCV
but doesn't work so i get error when compile on windows and linux
JCV
ok thanks
Álvaro
Can anybody help me with this? https://reverseengineering.stackexchange.com/questions/24870/how-to-debug-with-gdb-rbreak-in-order-to-obtain-a-callback-to-be-used-on-c-in thanks!!
Ajay
/report
Liam
/warn for offtopic.
Ajay
When we assign an integral value to an object of floating-point type, the fractional part is zero. Precision may be lost if the integer has more bits than the floating-point object can accommodate. Can anyone explain the 2nd line to me? An integer doesn't possess any digits after the decimal, so where is the talk about precision coming into picture?
Ajay
it shows 4294967296. Any reason for this imprecision? 4294967296 takes more than 4 bytes and float holds 4 bytes, then shouldn't this give undefined behaviour rather than value with lost precision?
Ajay
okay, thanx, i will do read that.
Anonymous
Hello
Joo
Whats the use of pointers to an array in c++ programming
Nils
Try float
Nils
So do float a,b,c
Nils
Instead of long long a,b,c
Nils
Hmmmm.... Well that's correct.
Nils
But what if number of digits after point is unknown?
Nils
Oh, okay.
Thank you @Rose!
James🤍
Write a program that asks the user to type 10 integers of an array. The program must output the largest element in the array, and the index at which that element was found.
James🤍
Yes but it's not running
_ghost
Write a program that asks the user to type 10 integers of an array. The program must output the largest element in the array, and the index at which that element was found.
You can store the elements into a vector and then call the max element function which returns an iterator to the max element which you can use to find the index as well as max number
James🤍
Has errors..
James🤍
Am using C++
James🤍
Okay in a few
James🤍
#include<iostream> using namespace std; int main() { int size; cout << "enter size of array : "; cin >> size; int arra[size]; int smallelement, largestelement; cout << "\nenter array elements : "; for (int i = 0; i < size; i++) { cin >> arra[i]; } largestelement = smallelement = arra[0]; for (int i = 0; i < size; i++) { if (arra[i] > largestelement) { largestelement = arra[i]; } if (arra[i] < smallelement) { smallelement = arra[i]; } } cout << "The biggest number is " << largestelement << endl; cout << "The smallest number is " << smallelement << endl; return 0; }
MᏫᎻᎯᎷᎷᎬᎠ
And delete [] arra; before return 0;
James🤍
And delete [] arra; before return 0;
Should i add thus line or what do you mean
James🤍
#include<iostream> using namespace std; int main() { int size; cout << "enter size of array : "; cin >> size; int* arra = new int[size] ; int smallelement, largestelement; cout << "\nenter array elements : "; for (int i = 0; i < size; i++) { cin >> arra[i]; } largestelement = smallelement = arra[0]; for (int i = 0; i < size; i++) { if (arra[i] > largestelement) { largestelement = arra[i]; } if (arra[i] < smallelement) { smallelement = arra[i]; } } cout << "The biggest number is " << largestelement << endl; cout << "The smallest number is " << smallelement << endl; delete [] arra; return 0; }
_ghost
Ya its not a useful feature but in C++ you can take the size of the array from the user first and then create an array of that size.
James🤍
Okay thanks
_ghost
Okay thanks
#include <iostream> #include <vector> #include <algorithm> int main(void) { int n; std :: cout << "Enter the size of the array: "; std :: cin >> n; std :: vector <int> sequence(n); std :: cout << "Enter the elements of the array: "; for(int i = 0; i < n; ++i) { std :: cin >> sequence[i]; } std :: cout << "The Smallest Number Is: " << *std :: min_element(sequence.begin(), sequence.end()) << std :: endl; std :: cout << "The Biggest Number Is: " << *std :: max_element(sequence.begin(), sequence.end()) << std :: endl; return 0; }
_ghost
Ya I already ran the program and it is completely fine, OK
_ghost
They are similar to an array in the sense that vectors store data in continuous memory locations but it is a dynamic array
Alion🦁
Hi! but, in C, C# we can do it, yeah?
Alion🦁
I used in C#, in c++, I didn't thanks for new information 🌹💚
_ghost
What's the point if I use vector I have more benefits than array.
Butikol12345
how can ı write a program that calculates the squares and cubes of the index values from 0 to 10. Additionally, you are expected to produce even and odd numbers. All values should be printed as seen in the output figure does anyone help me?
Alion🦁
how can ı write a program that calculates the squares and cubes of the index values from 0 to 10. Additionally, you are expected to produce even and odd numbers. All values should be printed as seen in the output figure does anyone help me?
Salam Semih, How r u? Yeah, if there is an interval, you should use loops. If we know exact start and finish point we should use for loop. do you know using of for loop?
Dima
lol
James🤍
Write a program that asks the user to type 10 integers of an array. The program must output the largest element in the array, and the index at which that element was found.
#include <iostream> using namespace std; int main() { int arr[10] ,max, i, j ; cout<< " Enter the 10 elements : \n" ; for(i=0; i<10; ++1) { cout<<" Element " <<i+1<<":"; cin>>arr[i] ; } for (j=0; j<10; ++j) { if(arr[j] >max) max=arr[j] ; } for(j=0; j<10; ++j) { if (arr[j] ==max) { cout<<" The largest element is : " <<max <<"at index :" <<j+1<<endl; } } return 0; } }
James🤍
With reference to the question.. Is this code correct.. Any modifications needed
Anonymous
Hello, can anyone give me a practical use of comparing pointers–especially void ones. I was reading and came across pointer comparisons. Although I did grasp “non-void” pointer comparisons and where we can use them but I’m not able to think of a scenario where I would find a reason to compare void pointers with others. Help...me..think. thanks edit: and and and how many pointer to pointers can one make ? int************** p ?? how many
_ghost
@ghost786 is the code correct.. In reference to the question
Code is correct but not scalable if you are working with large data. Moreover if you are finding the max and min by creating your own logic which is right, it will be better if you start studying and using STL which consists of some robust and efficient data structures using which you can write much better C++ programs.
Anonymous
ok fine, thanks and what about the pointer to pointers issue in my quest,ion ? how many can one perform, I just know it’ll be extremely hectic to follow, perhaps you might know the limit.
Anonymous
much obliged!
Nils
Hi, how can I define a function by typedef?
Nils
Hi, how can I define a function by typedef?
like: typedef std::function<int(char *argv[])> mode; mode { ... }