
- Forum
- Programming Talk
- C and C++
- Help! pls!
Help! pls!
This is a discussion on Help! pls! within the C and C++ forums, part of the Programming Talk category; -Write a program that works out the largest and smallest values from set of 10 inputted numbers...
-
Help! pls!
-Write a program that works out the largest and smallest values from set of 10 inputted numbers

-
12-16-2010, 01:05 PM #2
- Join Date
- Dec 2010
- Answers
- 32
int a[]=new int [10];
int max=a[0];
int min=a[9];
for (int i=0;i<10;i++)
{
if (a[i] > max)
{
max = a[i];
}
}
for (int j=9;j>0;j--)
{
if (a[j] < min)
{
min= a[j];
}
}
Print max n min
-
03-09-2012, 12:21 PM #3
- Join Date
- Feb 2012
- Answers
- 66
#include <stdio.h>
#include <stdlib.h>
#define n 100
int main(void)
{
int numbers[n];
int i = 1,j,input,maxval,minval;
printf("Enter the next array element>");
input = scanf("%d", &numbers[100]);
while (input != 0)
{
numbers[i] = input;
i++;
printf("Enter the next array element, while loop>");
input = scanf("%d", &numbers[n]);
if (input == 0)
{
printf("Enter the next array element, if loop");
numbers[i] = 0;
for (j =2;j <= i; j++)
{
minvalue = numbers[1];
j++;
if (numbers[j] > minvalue)
maxvalue = numbers[j] ;
else
minvalue = numbers[j] ;
}
}
}
printf("%f\t", maxvalue);
printf("%f\n", minvalue);
}
-
Sponsored Ads

Reply With Quote





