473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

hi there, ARRAYS && POINTERS

12
this is my programm, there is a mistake because it doesn't give the right answer; the quetion is below the program:
#include<stdio.h>
#define maxsize 100
void fillarray(double*, int);
void getminmax(double*, double*, double*, int);
int main() {
double WinNum, WinP, grades[maxsize];
int size,num,i;
printf("\n how many players are there:");
scanf("%d", &size);
fillarray(grades, size);
getminmax(grades, &WinNum, &WinP, size);
printf("The Random Number is: ");
scanf("%d", &num);
printf("\n Winning Number:%.2f ** Winning Player:%.2f",WinNum,WinP);
}
void fillarray(double* grade, int asize){
int i;
for(i=0;i<asize;i++){
printf("Player %d: ",i+1);
scanf("%lf",&grade[i]);
}
}
void getminmax(double* grade, double* WinNum, double* WinP, int num){
int i;
*WinNum = grade[0];
for(i=1; i<num; i++){
if (grade[i]< num)
*WinNum = grade[i];
*WinP=i-1;
}
}
The question: Write a program that gets as input an array of integers where every integer represents a number and player. The function will output the winning number and the winning player,
the winning number in closet one to a certani random number(Generated by
rand()). the winning player is its subscript in the array .
embed your function in a working program.
Nov 19 '06 #1
0 1121

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
64
by: Zytan | last post by:
I know there are no pointers in C#, but if you do: a = b; and a and b are both arrays, they now both point to the same memory (changing one changes the other). So, it makes them seem like...
1
by: Necromis | last post by:
I am trying to figure out a way to change the below code to store data in a multidemensional array rather than a listbox. The reason being is I need to be able to pull each "currentrow" and...
1
by: clickncook | last post by:
I'm currently working on a website for recipes that allows users to search by ingredients they have and I'm experiencing a problem with my filtering. My site allows users to just check the...
0
by: David Thompson | last post by:
On Wed, 09 Apr 2008 12:34:43 +0500, arnuld <arnVuld@ippiVmail.com> wrote: I think you've got the idea, but: - I would be careful about using 'equal'. Pointers and arrays are different things,...
2
by: Dandirom | last post by:
Hi guys, I need help. I'd appreciate any pointers on how to go about with this problem. Thanks a lot. Using arrays and/or pointers, make a prog that will ask for a string. 2 user-defined...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.