Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

C programming assignment

+1 vote
asked May 11, 2020 by Abhishek Pai (240 points)
How to find max and min value in an array of strings which contains very large numbers ?

For example in the array given below, the max value is 79837037403274 and min value is 80977907074

{"877320498384", "79837037403274", "80977907074", "587070509073"}

3 Answers

0 votes
answered May 13, 2020 by Juergen (300 points)
I would first search for the longest string in the array, then prefix all array members with '0' so all have the same length and finally use the sort function to sort alphabetically.
0 votes
answered May 13, 2020 by LiOS (6,460 points)
#include <stdio.h>

int main(){
    
    long int numbers[4] = {877320498384, 79837037403274, 80977907074, 587070509073};
    long int maximum = numbers[0], minimum = numbers[0];
    
    for(int counter = 0; counter < sizeof(numbers)/sizeof(numbers[0]); counter++){
        
        if(numbers[counter] > maximum){
            maximum = numbers[counter];
        }
        
        if(numbers[counter] < minimum){
             minimum = numbers[counter];
        }
        
    }
    
    printf("Maximum number in array = %lu \n", maximum);
    printf("Minimum number in array = %lu", minimum);

    return 0;
}
0 votes
answered May 13, 2020 by snowden1738 (150 points)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...