UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Program to accept a list of elements and find the maximum number in the list. 

 

Asked by Last Modified  

Follow 8
Answer

Please enter your answer

It Professional Trainer With 20 Years of Experience in in Key Aspects of Software Development

The logic will be 1. Create an array of the desired type 2. Sort the array in the descending order 3. Fetch the first elemnet from the array, this will be the maximum element in that array. Now use this logic to write code in the desired programming language.
read more

The logic will be 

1. Create an array of the desired type 

2. Sort the array in the descending order

3. Fetch the first elemnet from the array, this will be the maximum element in that array.

Now use this logic to write code in the desired programming language.

 

read less
Comments

Mobile App Developer

C programming code #include <stdio.h> int main() { int array, maximum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d", &size); printf("Enter %d integers\n", size); for (c = 0; c < size; c++) ...
read more

C programming code

    #include <stdio.h>
     
    int main()
    {
      int array[100], maximum, size, c, location = 1;
     
      printf("Enter the number of elements in array\n");
      scanf("%d", &size);
     
      printf("Enter %d integers\n", size);
     
      for (c = 0; c < size; c++)
        scanf("%d", &array[c]);
     
      maximum = array[0];
     
      for (c = 1; c < size; c++)
      {
        if (array[c] > maximum)
        {
           maximum  = array[c];
           location = c+1;
        }
      }
     
      printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
      return 0;
    }

read less
Comments

Mobile App Developer

C programming code #include <stdio.h> int main() { int array, maximum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d", &size); printf("Enter %d integers\n", size); for (c = 0; c < size; c++) ...
read more

C programming code

    #include <stdio.h>
     
    int main()
    {
      int array[100], maximum, size, c, location = 1;
     
      printf("Enter the number of elements in array\n");
      scanf("%d", &size);
     
      printf("Enter %d integers\n", size);
     
      for (c = 0; c < size; c++)
        scanf("%d", &array[c]);
     
      maximum = array[0];
     
      for (c = 1; c < size; c++)
      {
        if (array[c] > maximum)
        {
           maximum  = array[c];
           location = c+1;
        }
      }
     
      printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
      return 0;
    }

read less
Comments

S/W Engineer, Game Developer, Programmer, Trainer - 10 + Years Experience

using System; using System.Linq; public class abc { // returns maximum in arr of size n static int MaximumNumber(int arr, int n) { return arr.Max(); } static public void Main () { int arr = {10, 324, 45, 90, 9808}; int n = arr.Length; ...
read more
using System;
using System.Linq;
  
public class abc {
    // returns maximum in arr[] of size n
    static int MaximumNumber(int []arr, int n)
    {
        return arr.Max();
    }
    static public void Main ()
    {
        int []arr = {10, 324, 45, 90, 9808};
        int n = arr.Length;
        Console.WriteLine( MaximumNumber(arr, n));
    }
}
read less
Comments

Professor

# include<stdio.h> #include< conio.h> void main () { int a,n,i ,max; printf( " Enter no. of elements"); scanf("%d",&n); printf ("Enter all elements one by one"); for(I=0;I<n;I++) scanf("%d",&a); max=a; for( i=0; i<n; i++) { If( a>max) max= a; } printf...
read more

# include<stdio.h>

#include< conio.h>

void main ()

{

   int a[50],n,i ,max;

   printf( " Enter no. of elements");

   scanf("%d",&n);

  printf ("Enter all elements one by one");

for(I=0;I<n;I++)

scanf("%d",&a[i]);

max=a[ 0 ];

for( i=0; i<n; i++)

{

  If( a[ i ]>max)

  max= a[ i ];

}

printf ("Largest element: %d",max);

getch();

}

read less
Comments

Yoga Instructor

C language?
Comments

Yoga Instructor

#include<stdio.h> int main() { int a,i,n,large,small; printf("How many elements:"); scanf("%d",&n); printf("Enter the Array:"); for(i=0;i<n;++i) scanf("%d",&a); large=small=a; for(i=1;i<n;++i) { if(a>large) ...
read more

 

#include<stdio.h>

 

int main()

{

    int a[50],i,n,large,small;

    printf("How many elements:");

    scanf("%d",&n);

    printf("Enter the Array:");

 

    for(i=0;i<n;++i)

        scanf("%d",&a[i]);

    

    large=small=a[0];

    for(i=1;i<n;++i)

    {

        if(a[i]>large)

            large=a[i];

        if(a[i]<small)

            small=a[i];

    }

    

    printf("The largest element is %d",large);

    printf("\nThe smallest element is %d",small);

 

    return 0;

}

read less
Comments

Trainer

Use Max heap, every time accept a number and perform heapify operation. In the end, the element at root will be maximum. Time complexity, O(nlogn).
Comments

View 6 more Answers

Related Questions

How do I write code in C programming that will invert a string like "Welcome to programming" to “gnimmargorp ot emocleW”?
void main() { char msg = "Welcome to Programming"; char str; int i = 0, j = 0; clrscr(); while (msg != '\0') { if (msg != ' ') { str = msg; j++; ...
Mukul
What is the fee for learning C Language?
In C lang course ,there is not only basics it also having whole package to complete the task and course.cost may be it's depends upon the institute n teaching level
Sk.
How do I start learning C programming and finish it in one month?
Please follow the book "C Programming" by Detal & Detal. Its an applied book easy to understand compare to others. U may also learn through online free tutorial.
Pallavi
0 0
8
Can an array be an lvalue?
The answer to this question is no, because an array is composed of several separate array elements that cannot be treated as a whole for assignment purposes. The following statement is therefore illegal:...
Vinodha

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

C Language
To get help in C window (for keywords, functions) press Alt +F1.To delete a single line , use the shortcut key CTRL +Y.If you got error about the path when you execute a C pgm, check the Options menu =>Directories.
T

Thilagam S.

0 0
0

All About Programming And A Good Programmer.
Hi, This is my first lesson for you guys. Hope you enjoy reading it. In recent community questions, I found many people wanted to be good programmers, or wanted to have good hands on certain language,...

Tress And Its Traversal
Depth First Traversals:(a) Inorder (Left, Root, Right) : 4 2 5 1 3(b) Preorder (Root, Left, Right) : 1 2 4 5 3(c) Postorder (Left, Right, Root) : 4 5 2 3 1 Trees are one of the data structures like...

Understanding Computer Science Concepts with Images and Videos..
All Computer science concepts relating to programming and software development are only virtual. It cannot be practically shown as a hardware parts of a computer. But for better understanding it should...

C Program-Error Handling
//Header files #include<stdio.h>#include<conio.h>#include<stdlib.h> //Main function void main(){ int dividend=10; int divisor=0; int quotient; //Function for clearing screen clrscr(); ...

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more