Newsgroups: comp.os.msdos.djgpp Date: Thu, 19 Oct 2000 14:46:48 -0400 Message-ID: From: "Johan" Subject: Array problems... Lines: 55 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: smtpgate-01.ic.gc.ca X-Trace: 19 Oct 2000 15:00:14 -0500, smtpgate-01.ic.gc.ca To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi! I have some problems with my program. I want to take the numbers in array_a that are positive. 0 or above. And put these in array_b and print them out. You can see what I have done below and maybe someone can see what I have done wrong? I dont know.. I'm grateful for all help! /Johan --------------------- #include int main() { int array_a[] = {3, 2, 7, 0, 5, -4, 8, 7, -1, -9}; int array_b[7]; int n = 10; int m = 7; cout << "------ insu3_1 ------" << endl; for (int a = 0; a < n; a++) { cout << array_a[a] << " "; } cout << endl; // Prints out whats in array_a for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (array_a[i] >= 0) { array_b[j] += array_a[i]; } } } for (int b = 0; b < m; b++) // Prints out whats in array_b { cout << array_b[b] << " "; } cout << endl; return 0; } ---------------------------------