cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
If problem
If problem
Jan 24, 2015 at 4:38pm UTC
HelenI
(51)
Hey, I need help. I don't know why but the second part of the if it doesn't work.
And i don't get any number printed.
1
2
3
4
5
for
(i=0;i<n;i++){
for
(j=0;j<n;j++){
if
(a[i]*2==a[j] &&
a[i]/2==a[j]
) cout<<a[i]<<endl; }
Jan 24, 2015 at 5:04pm UTC
minomic
(226)
This is a maths problem: you have a number M and you want a number N such that N*2 = M and, at the same time, N/2 = M. Well, this number can only be 0! So probably there is something wrong: did you mean to make the OR of those conditions?
Jan 24, 2015 at 5:12pm UTC
HelenI
(51)
Thank you!! you made me find my mistake :)
Topic archived. No new replies allowed.