Thread: Reversing an array and printing it out

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2020
    Posts
    15

    Reversing an array and printing it out

    I've found a "problem" online. Text goes:

    Write C program that enables input of number n, (1 ≤ n ≤ 7) which stands for day of the week. If entered number does not correspond to any day, print error message of choice and ask user to repeat input of number n. For initialization of names of days use array of pointers. Print day user inputted. Use only pointer notation. Check which day has most consonants and print that day reversed.
    I had no problem with first part, but the last is one that bothers me. If I initialize an array of 7 elements (days) how do I check for number of consonants? My idea was to make separate array of consonants with 5 elements and do something with it. But, I'm stuck. Any help is appreciated. So far, without first part, I have this:

    Code:
    for (i = 0; i < 7; i++) {
        counter = 0;
        for (j = 0; (j < 20) || *(vowels + j) != '\0'; j++) {
            if (*(*(days + i) + j) != *(vowels + j))
                counter++;
            if (counter > temp) {
                temp = counter;
                index = i;
            }
        }
    }
    Last edited by 574515; 03-30-2020 at 02:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reversing elements in an array
    By supermcbrownie in forum C Programming
    Replies: 5
    Last Post: 04-16-2014, 05:14 PM
  2. Reversing an array
    By YannB in forum C Programming
    Replies: 4
    Last Post: 01-28-2014, 04:58 PM
  3. Need help in reversing words in an Array
    By Justin Page in forum C Programming
    Replies: 8
    Last Post: 07-22-2012, 12:18 AM
  4. string array reversing...
    By cit in forum C Programming
    Replies: 4
    Last Post: 03-28-2002, 03:09 AM
  5. Reversing a Multi-D Array
    By Bradley33 in forum C++ Programming
    Replies: 1
    Last Post: 11-19-2001, 11:37 AM

Tags for this Thread