Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C programming arrays?

I have this program to write and since I am very new in C programming I need some help.

"Write program that reads the number of elements N and the elements (long) in one-dimensional array (maximum size 50). The program calculates and displays the maximum point and the positions in which it appears. Try to solve the problem with a single "scan" of the table."

What confuses me is the last sentence: "Try to solve the problem with a single "scan" of the table."

2 Answers

Relevance
  • 10 years ago

    "Try to solve the problem with a single "scan" of the table."

    for finding the maximum number in the single dimention array u need to check each value of the array

    here single scan means u can read the array i mean all its member only once

    take a variable max initialize it with the first element of given array

    take a int type variable name position and initialize that to 0;

    take a variable i and initialize that to 0;

    run a loop for int i=0 to length of array

    if max > array[i] {

    max = array[i]

    position=i

    }

    finallyprint max and position

  • 4 years ago

    the 1st answer isn't too undesirable. i think of of i might make it somewhat smaller and use isalpha() and strchr() ought to be purifier. char *vowels="aeiouAEIUO"; int countvows(char *strptr, vowels) { int circumstances = 0; on an identical time as(*strptr) { if(isalpha(*strptr)) { // everybody be conscious of this is a-zA-Z now if(strchr(vowels,*strptr)) // this is a vowel circumstances++; strptr++; } // if } // on an identical time as consonants ought to be an identical technique extremely , distinctive than the if() ought to be: if(!strchr(vowels,*strptr)) // this is a consonant }

Still have questions? Get your answers by asking now.