Write a program that first reads at most 30 numbers of type

Write a program that first reads at most 30 numbers of type double from the user (the user will type character quit when finished), and stores these values in an array in the same order that they were entered by the user. Your program should then call the function reverse array with this array as an argument, and finally displays the new contents of the array to the screen, 5 values per line. Sample Input/Output: (the user\'s input is shown in bold) Please enter at most 30 numbers; type quit when finished 1396 470 -9 -1 9180-5011 02 -275 13 216 15-7 quit The array in reverse order (5 values per line) is -715 216 13-275 2 0-5011 9180-1 -9 470 1396

Solution

#include <stdio.h>
#include<string.h>

void reverse(char arr[], int size){
   strrev(arr);
   int i;
   for(i=0; i<size; i++){
       if(i>0 && (i%5 == 0)){
           printf(\"\ \");
       }
       printf(\"%s \",arr[i]);
   }
}
int main(){
   //declaring array of size 30
   char arr[30];
   int i; // loop index variable declaration
   int length = 0;
   //reading words from user
   printf(\"Enter \'quit\' to stop entering words. \");
   //loop starts here
   for(i=0;i<30;i++){
       char word[20];
       scanf(\"%s\",word);
       if(strcmp(word,\"quit\") == 0){
           break; //stop reading
       }
       stpcpy(arr[i],word);
       length++;
   }
   //reversing array
   reverse(arr,length);
}

 Write a program that first reads at most 30 numbers of type double from the user (the user will type character quit when finished), and stores these values in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site