Thread: Rotating arrays

  1. #1
    Registered User
    Join Date
    Jun 2015
    Posts
    2

    Rotating arrays

    Can someone help me this programme please. The question is:

    Write a C program that accepts by keyboard input eight (8) user-ratings of the Galaxy S5. The ratings use a scale of 1 to 10, where 10 represents a high rating and 1 represents a low rating:
    1) Prints the lowest and highest rating received for the S5.
    2) Calculates and prints the average of the ratings.
    3) Determines and prints the average ratings performance as "Excellent" if the average is between 7.5 and 10, "Average" if the average is between 5.5 and 7.4, and "Poor" if the average is between 0 and 5.4.

    Code:
    #include<stdio.h>
    /*Samsung S5 user ratings*/
    int main (void) {
        int average;
        int total;
        int rate;
        int counter;
        int smallest;
        int largest;
        int i;
        counter = 1;
        total = 0;
            while (counter<=8) {
            printf ("Please enter a rate: ");
            scanf ("%d",&rate);
            total = total + 1;
            counter = counter +1;
        }
        /*Find the largest number*/
        largest = rate;
        for (i=0; i<8; i++){
            if (rate>largest)
            largest = rate;
        }
        printf ("The largest number is:%d\n", largest);
        /*Find the smallest number*/
        smallest = rate;
        for (i=0; i<8; i++){
            if (rate<smallest)
            smallest = rate;
        }
        printf ("The smallest number is:%d\n", smallest);
        /*Find the average rate for the S5*/
        average = rate/8;
        printf ("The average is %d\n",&average);
        
        if ((average >= 7.5) || (average >= 10)){
            printf ("S5 rate is Excellent");
        }
        else if ((average >= 5.5) || (average >= 7.4)){
            printf ("S5 rate is Average");
        }
        else if ((average >= 0) || (average >= 5.4)){
            printf ("S5 rate is poor");
        }
    }
    That is my prgramme so far but its not compiling correctly.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Perhaps you'd be better off solving the problems with your first program, before working on another.

    Regarding this one, you should post the warnings and errors you receive from your compiler.

    I see some very basic problems with the logic in the code, so my advice from the other thread is revelant here, too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rotating a Matrix
    By ThLstN in forum C Programming
    Replies: 15
    Last Post: 01-25-2008, 04:08 AM
  2. Rotating Log
    By BobS0327 in forum C Programming
    Replies: 4
    Last Post: 09-08-2005, 05:08 AM
  3. Need Help Rotating these values.
    By RP319 in forum C++ Programming
    Replies: 6
    Last Post: 02-15-2005, 09:56 PM
  4. Rotating part of a dc
    By Mithoric in forum Windows Programming
    Replies: 4
    Last Post: 06-05-2004, 01:42 PM