i am trying to do a program that reads in an arbitrary number of lists of integers.
-A valid list of integers consists of AT MOST (could be less than) 20 integers.
-You can be given less than 20 numbers.
-You might be given more than 20 numbers. This means that the list is invalid.

If a list has 20 integers or less, you should then:
-Print what number list this is (1st one you read, second, etc.)
-Print the list in the order it was given
-Print the sum
-Print the average
-Print the list sorted from least to greatest

Check if there is another list to process; if yes, there will be an asterisk character.
-Any character that is not an asterisk means there are no more lists to process.

i wanted to know if i am off the the right start. still fairly new to programing so any advise as to what direction to head would be appreciated.

#include <stdio.h>

#define SIZE 20

int main(void){
  int i = 0;
  int arr[SIZE]; 
  int n;

  while (i < SIZE){
    int n = scanf("%d", &arr[i]);
  if (n == 1){
    printf("%d\n", arr[i]);

Edited by hoganmadman: n/a

7 Years
Discussion Span
Last Post by fdsa99

From your given description,you need to make a file from which you will get the list of integers. Then check the list contains 20 integers or more. For that you need to find end of the list. That will help you to count the number of integers. Then you can perform all the operation like average, sum and sorting also.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.