/*
Alamgir Hossain
Lecturer, Dept. of CSE, Prime University.
C program to find maximum and minimum element in array.
Example: 20, 17, 10, 5, 50
Max: 50
Min: 5
Logic:
1. Input size and element in array, store it in some variable say size and arr.
2. Declare max and min to store maximum and minimum element.
Assume first array element as maximum and minimum both,
so, max = arr[0] and min = arr[0].
3. Run loop from first to last array element i.e. 0 to size - 1
4. Inside loop check each array elements,
if (arr[i] > max), then update max = arr[i];
if (arr[i] < min), then update min = arr[i];
*/
#include<stdio.h>
int main()
{
int size, arr[100], max, min, i;
printf("Enter the size of the array: ");
scanf("%d", &size);
printf("Enter the elements of the array: ");
for(i = 0; i < size; i++){
scanf("%d", &arr[i]);
}
max = min = arr[0];
for(i = 0; i < size; i++){
if(max < arr[i]){
max = arr[i];
}
if(min > arr[i]){
min = arr[i];
}
}
printf("Maximum is : %d\n", max);
printf("Minimum is: %d\n", min);
return 0;
}
C program to find maximum and minimum element in an array
By
Alamgir Hossain
C
Click any Bellow Tabs/Tags
Alamgir-Hossain
(14)
Algorithms
(5)
Android problem
(2)
ANN
(1)
ArticleWriting
(26)
Artificial Intelligence
(1)
Assembly
(1)
Bangla Love Poem
(3)
Bangla Poem
(2)
best programming solution
(9)
Books
(2)
BUET IICT MSC Admission
-2021
(1)
C
(49)
Campus
(7)
CPP
(88)
Database
(4)
Differences
(2)
Fishing
(1)
HSC
(1)
Html
(4)
interesting programming solution
(9)
Interview
(2)
It job preparation
(7)
JAVA
(97)
JavaScript
(5)
JSON
(1)
lead generation
(1)
machine learning
(2)
ML Projects
(3)
NewsPaper
(19)
Others
(13)
Perl
(23)
Php
(4)
Poem
(4)
Presentation
(1)
ProblemSolving
(3)
Project
(21)
Prolog
(13)
Python
(33)
research
(18)
Research Tool
(1)
Security
(3)
Social Engineering
(1)
Testimonials
(5)
Tutorial
(2)
Writings
(15)
XML
(1)
YoutubeSEO
(1)
উক্তি
(1)
কবিতা-আলগীর হোসেন
(2)
লেখনী
(33)
LATEST
3-latest-65px
Popular Posts
-
All instructions for connection & insert data in mysql from java JSP and Servlet using tomcat serverFrom this tutorial you can learn about... All instructions for connection & insert data in mysql from java JSP and Servlet using tomc...
-
% Prolog program for addition and multplication-------- % Alamgir Hossain % CSE, JUST go :- write ( 'Enter first number : ' ...
-
Inverse Lagrange’s Interpolation Formula Theory : . Example : 1. Use Lagrange’s inverse interpolation fo...
-
Project Name : Online examination system. Framework : MVC framework in java(3 layer architecture). Language: JAVA JSP, SERVLET, JS...
-
Here is the source code for online exam system using PHP, MYSQL,AJAX, JAVASCRIPT etc.... Source code for Online Exam System
This is a great post. Your Blog the very informative i have learned some information about your blog.
ReplyDeletePhp projects with source code
Online examination system in php
Student management system in php
Php projects for students
Free source code for academic
Academic projects provider in nashik
Academic project free download