| | |
Need hellp with my array
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
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 beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






