-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindSmallestValue.c
44 lines (37 loc) · 943 Bytes
/
findSmallestValue.c
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
/**
* @file findSmallestValue.c
* Write a C program to read an array of length 6 and find the smallest element and its position.
* @author Md. Alamin ([email protected])
* I would love be a software engineer at Google. That is why anybody can uses this code without any condition, if you face any difficulty, then try to email me.
* @version 0.1
* @date 2022-04-01
*
* @copyright Copyright (c) 2022
*
*/
#include <stdio.h>
int main()
{
int n, t = 0, pos, i;
printf("Enter array length: \n");
scanf("%d", &n);
int a[n];
printf("Enter array value: \n");
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
t = a[0];
pos = 0;
for (i = 1; i < n; i++)
{
if (t > a[i])
{
t = a[i];
pos = i+1;
}
}
printf("Smallest value is : %d\n", t);
printf("Smallest value position is : %d\n", pos);
return 0;
}