why am getting nan on performing below operation?
#include <bits/stdc++.h> using namespace std; int main() { int a[2] = {-1,1}; for (int i=0; i<2; i++){ cout<<exp(log(-1)-log(a[i])); cout<<endl; } return 0; } output :- nan nan I am expecting output:- [1,-1] I am trying to perform division using exp and log properties c++ arrays math New contributor Harsh Gola is a new contributor to […]
Multiply all elements of an array by a scalar until they all add up to a certain value
Let’s say I have an array float array[7] = {0.1, 0.2, 0.4, 0.8, 0.4, 0.2, 0.1};