| | |
Need hellp with my array
![]() |
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
I am working on displaying the amount ofodd numbers in this array. It always says there is 5. That is not correct. When I use the debug it shows that it is placing a different value in the myArray and using that to determine the amount of odd numbers. Please someone take a look.
<< moderator edit: added code tags: [code][/code] >>
C++ Syntax (Toggle Plain Text)
#include <iostream> using std::cout; using std::endl; const int MAX = 10; int myArray[MAX] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11}; int odd = 0; int main() { for (int i = 1; i < MAX; i++) { if ((i%2)==1) odd++; } cout << "Number of odd integers: " << odd << endl; return 0; }
![]() |
Similar Threads
- HELLP in graphing using 2d array in c++ (C++)
- Array limit (C)
- string to integer array transformation (C)
- Array (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: airplane seating prices
- Next Thread: newcommer to c++ need help with simple program
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez graph guess gui homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators infinite input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem proficiency program programming project python random read recursion reference rpg string strings temperature template templates test text text-file tree url variable vector video win32 windows winsock word wordfrequency wxwidgets






