Previous Next
0 / 21
Module DEMO-32-106DEMO-C-32

Find Maximum Element

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a C program to find the maximum element in a 1D array. Input the size n and then n integers. Output the largest value present in the array.

Example

Input:

5 1 5 3 9 2

Output:

9

Constraints

1 <= n <= 100

Input Format

n followed by array elements.

Output Format

The maximum value.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
5
1 5 3 9 2
9
Max of 1, 5, 3, 9, 2 is 9.
Sample #2
Public sample
3
-10 -2 -5
-2
Max of negatives (-10, -2, -5) is -2.
Sample #3
Public sample
1
42
42
Single element is the max.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings