-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathQ5.c
More file actions
26 lines (26 loc) · 634 Bytes
/
Q5.c
File metadata and controls
26 lines (26 loc) · 634 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
/* Program:- 5
Read an array of 8 integers and also read a number to be searched. If search number is found
then print its position & if not found then print appropriate message.
*/
#include <stdio.h>
#include <stdlib.h>
void main()
{
int num[8], i, n;
printf("Enter the 8 integers number: ");
for (i = 0; i < 8; i++)
{
scanf("%d", &num[i]);
}
printf("Enter a number we want to find: ");
scanf("%d", &n);
for (i = 0; i < 8; i++)
{
if (n == num[i])
{
printf("Position %d of number %d. is", i, n);
exit(0);
}
}
printf("Number %d not found", n);
}