๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ examples โ€บ array-largest-element
C Program to Find Largest Element in an Array
... #include <stdio.h> int main() { int n; double arr[100]; printf("Enter the number of elements (1 to 100): "); scanf("%d", &n); for (int i = 0; i < n; ++i) { printf("Enter number%d: ", i + 1); scanf("%lf", &arr[i]); } // storing the largest number to arr[0] for (int i = 1; i < n; ++i) { if ...
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ examples โ€บ largest-number-three
C Program to Find the Largest Number Among Three Numbers
Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified C programmer. Try Programiz PRO! ... #include <stdio.h> int main() { double n1, n2, n3; printf("Enter three different numbers: "); scanf("%lf %lf %lf", &n1, &n2, &n3); // if n1 is greater than both n2 and n3, n1 is the largest if (n1 >= n2 && n1 >= n3) printf("%.2f is the largest number.", n1); // if n2 is greater than both n1 and n3, n2 is the largest if (n2 >= n1 && n2 >= n3) printf("%.2f is the largest number.", n2); // if n3 is greater than both n1 and n2, n3 is the largest if (n3 >= n1 && n3 >= n2) printf("%.2f is the largest number.", n3); return 0; }
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ c-find-the-largest-number-among-n-numbers-123252
Find the Largest Number Among N Numbers
This is a fundamental programming exercise that teaches several important concepts: ... The algorithm we will implement is straightforward: we will ask the user how many numbers they want to enter, then iterate through each input number.
๐ŸŒ
The Science 360
thescience360.com โ€บ home โ€บ programming โ€บ c program to find largest of n numbers
C program to find largest of N Numbers : The Science 360
January 1, 2024 - C programming techniques to find the largest of N numbers with different types of shorting algorithms.
๐ŸŒ
CODEDOST
codedost.com โ€บ home โ€บ array&pointers in c โ€บ c program to find largest of n numbers in a given array
C program to find largest of n numbers in a given array | CODEDOST
July 23, 2025 - We start to iterate and then compare all the elements with each other and store the largest element in the variable named โ€˜largeโ€™ and then keep comparing till we find the largest element. Take input array โ€˜aโ€™ and no of elements(n) as 4 ยท Let us take elements for array a={7,8,12,3}. ... #include<stdio.h> void main() { int i,n,a[100],large; printf("Enter the number of elements:\n") ; scanf("%d",&n) ; printf("Enter the elements\n") ; for(i=0;i<n;i++) { scanf("%d",&a[i]) ; } large=a[0]; for(i=1;i<n;i++) { if(large<a[i]) { large=a[i]; } } printf("Largest of %d elements in an array = %d",n,large); }
๐ŸŒ
Tutorjoes
tutorjoes.in โ€บ c_programming_tutorial โ€บ greatest_array_in_c
Finding the Largest Number among a Set of Numbers in C
#include<stdio.h> int main() { int i,n,t,a[100]; printf("\nEnter The Limit : "); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter The Value : "); scanf("%d",&a[i]); } t=a[0]; for(i=1;i<n;i++) { if(t<a[i]) t=a[i]; } printf("\nThe Greatest No is %d",t); return 0; } To download raw file Click Here ยท Enter The Limit : 5 Enter The Value : 23 Enter The Value : 34 Enter The Value : 12 Enter The Value : 3 Enter The Value : 56 The Greatest No is 56
๐ŸŒ
StackHowTo
stackhowto.com โ€บ home โ€บ c program to find largest of n numbers using while loop
C Program To Find Largest Of N Numbers Using While Loop - StackHowTo
May 23, 2025 - Then in the loop, we compare it with each input entered by the user. #include <stdio.h> int main(void) { int n; int max = 0; printf("Enter a number (0 to exit): "); scanf("%d", &n); while (n != 0) { if (max < n) { max = n; } printf("Enter a number (0 to exit): "); scanf("%d", &n); } printf("Max is: %d", max); } ... Enter a number (0 to exit): 2 Enter a number (0 to exit): 5 Enter a number (0 to exit): 4 Enter a number (0 to exit): 3 Enter a number (0 to exit): 9 Enter a number (0 to exit): 1 Enter a number (0 to exit): 0 Max is: 9
๐ŸŒ
Cquestions
cquestions.com โ€บ 2011 โ€บ 09 โ€บ program-to-find-largest-of-n-numbers-in.html
C programming Interview questions and answers: Program to find largest of n numbers in c
September 1, 2011 - #include void main(){ int i,j,num[4],big; printf("Enter 3 Numbers\n "); for(i=0;i<3;i++) scanf("%d",&num[i]); big=num[0]; for(j=1;j<3;j++){ if(big<num[j]) big=num[j]; } printf("Largest number is: %d",big); } ... SindhujaSelvaraj said... This comment has been removed by the author.
๐ŸŒ
Blogger
programers-guide.blogspot.com โ€บ 2012 โ€บ 06 โ€บ c-program-to-find-largest-and-smallest.html
PROGRAMMING GUIDE: C Program to find the largest and smallest of N numbers
September 3, 2020 - Blog contains programs, source code, tutorial of C and Java ... #include "stdio.h" void main () { int i, j, n, a[20], max, min; clrscr (); printf ("Please enter the limit\n"); scanf ("%d", &n); printf ("Please enter the numbers\n"); for (i = 0; i < n; i++) { scanf ("%d", &a[i]); } max = a[0]; min = a[0]; for (i = 0; i < n; i++) { if (a[i] > max) { max = a[i]; } else if (a[i] < min) { min = a[i]; } } printf ("Largest number is %d\nSmallest number is %d", max, min); getch (); }
Find elsewhere
๐ŸŒ
Codesansar
codesansar.com โ€บ c-programming-examples โ€บ largest-from-n-numbers.htm
C Program to Find Largest from N Numbers
August 19, 2022 - How many numbers? 4 โ†ฒ Enter number-1: 67 โ†ฒ Enter number-2: 89 โ†ฒ Enter number-3: 99 โ†ฒ Enter number-4: 56 โ†ฒ Largest = 99.00 Note: โ†ฒ indicates ENTER is pressed. ... C program to print Hello, World! ... Sum of 1+11+111+1111 ...
Top answer
1 of 2
4

Since none of the previously entered salaries are needed to calculate ...

  • the largest commission
  • the total takehome

... you can skip the num[10] array.

  • You do need to increase i in the loop. i+1 is an expression which does not change the value of i. I suggest using a for loop for this which keeps the declaration of i, the condition (i < 10) and the increment nicely in one place.
  • You should check the return value from scanf. If you scan for one thing, it should return 1, otherwise it failed.
  • Save the largest commission in the loop.
  • Initialize variables.
  • Add to totaltakehome. You currently assign a new value to it in every loop.

Example:

#include <stdio.h>

int main() {
    int largest = 0;       // initialized (and assuming this can't be negative)
    int totaltakehome = 0; // initialized

    for(int i = 0; i < 10; ++i) {  // loop with increment
        printf("Enter salesperson salary for week[%d]:", i + 1);

        int num;
        if(scanf("%d", &num) != 1) {   // check for success
            fprintf(stderr, "user error, aborting\n");
            return 1;
        }

        // an alternative commission forumla
        int com = num * 7 / 100; // perhaps a more fair commission

        printf("Commision is %d\n", com);

        // save this commission if it's the largest so far:
        if(com > largest) largest = com;

        // Add to `totaltakehome` - don't assign:
        totaltakehome += 300 + com;    // note: `+=`, not `=`

        printf("\n");
    }

    // print results after the loop:
    printf("Largest commision %d\n", largest);
    printf("Total takehome is %d\n", totaltakehome);
}
2 of 2
1

We can use a basic for loop for the answer.

int old = arr[0];
for (i = 0; i < 10; i++) {
    if (arr[i] > old) old = arr[i];
}

return old;

First we create a loop that runs ten times or we can also use

sizeof(arr)/sizeof(arr[0])

For an unknown list size. Forgive me for I am on mobile.

Then we check if the next number is bigger than our old biggest known if so set it to be the biggest. If so, we will set it to be our biggest. Then we finally return our value. (This is a function btw)

๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ c-program-biggest-3-numbers
Largest of Three Numbers in C - Sanfoundry
July 29, 2025 - Enter the values of num1, num2 ... is the largest number. ... In this approach, we will use ternary operator to find the biggest number. ... Here, a > b -> Condition. If it satisfies it will check (a > c ? a : c) else (b > c ? b : c). 22 > 14, ...
๐ŸŒ
W3Schools
w3schools.in โ€บ c-programming โ€บ examples โ€บ find-the-greatest-among-ten-numbers
C Program to Find the Greatest Among Ten Numbers
This C Program is used to find the greatest among ten numbers. Program: #include <stdio.h> int main() { int a[10]; int i; int greatest; printf("Enter ten values...
๐ŸŒ
Aticleworld
aticleworld.com โ€บ home โ€บ c program to find largest of three given numbers
C program to find largest of three given numbers - Aticleworld
December 25, 2023 - #include <stdio.h> int main() { ... printf("\n Enter the number3 = "); scanf("%d", &num3); if (num1 >= num2 && num1 >= num3) { printf("\n %d is the largest number.\n", num1); } if (num2 >= num1 && num2 >= num3) { printf("\n ...
๐ŸŒ
Programtopia
programtopia.net โ€บ home โ€บ c examples โ€บ c program to find largest and smallest number among n numbers
C Program to Find Largest and Smallest Number among N Numbers - Programtopia
January 15, 2021 - C program to find the largest and ... i++) { printf ("n Enter another number n"); scanf ("%d",&n); if (n>lar) lar=n; if (n<sm) sm=n; } printf ("n The largest number is %d", lar); printf ("n The smallest number is %d", sm); return 0; }...
๐ŸŒ
Studytonight
studytonight.com โ€บ c โ€บ programs โ€บ numbers โ€บ finding-largest-among-n-numbers
Program to find the Largest number among N input Numbers | C Programs | Studytonight
#include<stdio.h> int main() { printf("\n\n\t\tStudytonight - Best place to learn\n\n\n"); int n,i; float c,big; printf("\n\nEnter the number of elements you wish to find the greatest element of: "); scanf("%d", &n); printf("\n\nEnter %d numbers :\n", n); printf("\n\n\t\t\tElement 1: "); //Important step- always initialize big to the first element scanf("%f", &big); for(i = 2; i <= n; i++) { printf("\n\t\t\tElement %d : ", i); scanf("%f", &c); /* if input number is larger than the current largest number */ if(big < c) big = c; // update big to the larger value } printf("\n\n\nThe largest of the %d numbers is %f ", n, big); printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n"); return 0; }
๐ŸŒ
Aticleworld
aticleworld.com โ€บ home โ€บ c program to find largest of two given numbers
C program to find largest of two given numbers - Aticleworld
August 22, 2022 - #include <stdio.h> int main() { ... &num2); if(num1 > num2) { printf("%d is Largest\n", num1); } else if (num2 > num1) { printf("%d is Largest\n", num2); } else { printf("Both are Equal\n"); } return 0; }...
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ c-program-to-find-largest-number-in-an-array
C Program to Find Largest Number in an Array
August 31, 2023 - The Following printf statement is to print the Index Position of the Largest Number inside it. In this C program example, it is occurs at position 2 ยท printf("\nIndex position of the Largest element = %d", Position);