Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Passing Arguments | Functions
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C Basics
close
Section 5. Chapter 4
single

single

bookPassing Arguments

Swipe to show menu

Finding the Maximum Element in an Array

main.c

main.c

copy
123456789101112131415161718192021222324252627
#include <stdio.h> int findMaxElement(int arr[]) // 1 { int max = arr[0]; // 2 for (int i = 1; i < 5; i++) // 3 { if (arr[i] > max) // 3 { max = arr[i]; // 4 } } return max; } int main() { int array[] = { 10, 5, 7, 14, 3 }; int maxElement = findMaxElement(array); printf("Max element is: %d\n", maxElement); return 0; }
Task

Swipe to start coding

Craft a function that determines the smallest element of an array.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 5. Chapter 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt