forked from shivammaniharsahu/coding_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp_2_18115004.cpp
More file actions
50 lines (42 loc) · 827 Bytes
/
exp_2_18115004.cpp
File metadata and controls
50 lines (42 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
void prtnm()
{
cout<<"Name: Ajay Kumar\n";
cout<<"Roll No: 18115004 \n";
cout<<"Prg. No: 2\n";
cout<<"\n\n";
}
int main()
{
prtnm();
int i,j,temp=1,n,max,min,pos=1;
printf("Enter No. of element = ");
cin>>n;
int ar[n];
printf("Enter array of value\n");
for(i=0;i<n;i++)
{
cin>>ar[i];
}
max=ar[0];
for(i=0;i<n;i++)
{
if(max<ar[i])
{
max=ar[i];
pos=i+1;
}
}
printf("Max value is = %d and index = %d\n",max,pos);
min=ar[0];
for(i=0;i<n;i++)
{
if(min>ar[i])
{
min=ar[i];
temp=i+1;
}
}
printf("Min value is = %d and index = %d",min,temp);
}