Home
About
Desclaimer
Privacy Policy
Terms of Services
Python
C/C++
Java
HTML/CSS
Home
About
Desclaimer
Privacy Policy
Term of Services
Python
C/C++
Java
HTML/CSS
Ad Code
Responsive Advertisement
Categories
C Program
(10)
c++ Programs
(3)
Search This Blog
Powered by Blogger
December 2022
13
Report Abuse
About Me
Universal Programmers
View my complete profile
Home
C Program
Write a program in C to read 7 integer values from the user in an array and display the maximum and minimum element.
Write a program in C to read 7 integer values from the user in an array and display the maximum and minimum element.
Universal Programmers
December 30, 2022
Answer
Copy
#include
#include
int main(void) { / Declare an array to store the integers int arr[7]; / Read the integers from the user printf("Enter 7 integers: "); for (int i = 0; i < 7; i+ +) { scanf("%d", &arr[i]); }/ Initialize variables to store the maximum and minimum elements int max = arr[0]; int min = arr[0]; / Find the maximum and minimum elements for (int i = 1; i < 7; i++) { if (arr[i] > max) { max = arr[i]; } if (arr[i] < min) { min = arr[i]; } }/ Print the maximum and minimum elements printf("Maximum element: %d\n", max); printf("Minimum element: %d\n", min); return 0; }
OUTPUT
C Program
Post a Comment
0 Comments
Social Plugin
Popular Posts
Subscribe Us
Facebook
Tags
Close Menu
0 Comments