| | |
something worng with my program need help please,,
![]() |
•
•
Join Date: May 2005
Posts: 4
Reputation:
Solved Threads: 0
hi,, the program i made is soppost to reads 3 integers from user and solve the average, the maximum, the minimum and their median value..the problem with the program is that the median section is not working, can u please have a look at it..
<< moderator edit: added [code][/code] tags >>
But now, I can't run the program because there are some errors, all saying:
1.C:42: invalid types `int[100][float]' for array subscript
1.C:46: invalid types `int[100][float]' for array subscript
1.C:47: invalid types `int[100][float]' for array subscript
1.C:48: invalid types `int[100][float]' for array subscript
1.C:49: invalid types `int[100][float]' for array subscript
1.C:66: invalid types `int[100][float]' for array subscript
What did I do wrong? Could anybody help me please?
Thank You.
C++ Syntax (Toggle Plain Text)
#include<stdio.h> main( ) { int item[100]; float a, b, c; int median_index; float median; int count; float sum; printf("Enter your first integer\n"); scanf(" %f", & a); printf("Enter your second integer\n"); scanf(" %f", & b); printf("Enter your third integer\n"); scanf(" %f", & c); sum = (a + b + c)/3; for(a=0; a<count; a++){ scanf("%f", &item[a]); } for(a=1; a<count; a++) for(b=count-1; b>=a; --b){ if(item[b-1] > item[b]){ c=item[b-1]; item[b-1] = item[b]; item[b]=c; } } median = count/2; if(count%2 ==1){ printf("There are odd sets of numbers.\n"); median = item[count/2]; } else{ median_index = count/2; printf("There are even sets of numbers.\n"); median = (item[median_index]+item[median_index-1])/2.0; } for(c=0; c<count; c++){ printf("%f\n", item[c]); } printf("\nThe average is %0.2f\n", sum); printf("The median is %0.2f\n", median); if ((a > b) && (a > c)) printf("The maximum %0.2f\n", a); else if ((b> a) && (b> c)) printf("The maximum is %0.2f\n", b); else printf("The maximum is %0.2f\n", c); if ((a < b) && (a < c)) printf("The minimum is %0.2f", a); else if ((b < a) && (b < c)) printf("The minimum is %0.2f", b); else printf("The minimum is %0.2f", c); return 0; }
But now, I can't run the program because there are some errors, all saying:
1.C:42: invalid types `int[100][float]' for array subscript
1.C:46: invalid types `int[100][float]' for array subscript
1.C:47: invalid types `int[100][float]' for array subscript
1.C:48: invalid types `int[100][float]' for array subscript
1.C:49: invalid types `int[100][float]' for array subscript
1.C:66: invalid types `int[100][float]' for array subscript
What did I do wrong? Could anybody help me please?
Thank You.
•
•
•
•
Originally Posted by idris
now the porgram runs but it doesn't go through any of the loops (it only ask the user to enter the 3 integers and after that stops), why do u think dat is?
“The essential notion of a socialist society is force.”
— Milton Friedman
— Milton Friedman
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- What's the HARDEST program you've written? (Computer Science)
- Cool little Program to disable startup programs (Windows NT / 2000 / XP)
- Java Problem with running program (Java)
- Program is shutting down right after program is executed (C++)
- 3d Program (Game Development)
Other Threads in the C++ Forum
- Previous Thread: help with updating a text file using C++
- Next Thread: Printing
Views: 2935 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 algorithm array arrays assignment beginner binary c++ c/c++ calculator char class classes code command compile compiler constructor conversion convert count data delete dll dynamic encryption error file files forms fstream function functions game givemetehcodez graph gui helpwithhomework homework http iamthwee ifstream input int lazy linker list loop loops map math matrix memory network newbie number object objects opengl operator output parameter path pointer pointers problem program programming project random read recursion recursive reference simple sockets sort spoonfeeding string strings struct student studio template templates text time tree variable vc++ vector video visual void win32 window windows winsock wordfrequency wxwidgets






