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; }
Videos
C32 - Program to find the biggest of N numbers using arrays ...
02:35
C Program To Find Biggest of N Numbers, without using Arrays, using ...
02:14
Find Biggest of N Numbers, without using Arrays: C Program - YouTube
11.Simple C Program to Find Largest Number among Three Numbers ...
08:57
C Program to find largest of three numbers with out using if ...
02:39
C Program To Find First and Second Biggest in N Numbers, without ...
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 (); }
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
iin the loop.i+1is an expression which does not change the value ofi. I suggest using aforloop for this which keeps the declaration ofi, 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 return1, 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)
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...
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; }