Answer to Question #217501 in C for Sanjay

Question #217501
The supermarket has different variety of items in different weight. Find maximum weight from these items. Write a C program to find maximum weight of an item using pointer.
1
Expert's answer
2021-07-16T01:04:34-0400
#include <stdio.h>
#include <stdlib.h>


int main(int argc, char* argv[]) 
{
    double weights[11] = { 10.1, 11.2, 1.2, 4.5, 11.4, 11.5, 12.5, 10.4, 9.8, 7.6, 6.2 };
    double *max_ptr = NULL;
    double *current_ptr = weights;
    int i;
    
    for (i = 0; i < 11; i++, current_ptr++)
    {
        if (!max_ptr || (*max_ptr < *current_ptr))
            max_ptr = current_ptr;        
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS