SHOW:
|
|
- or go back to the newest paste.
1 | - | #include <stdio.h> |
1 | + | #include<stdio.h> |
2 | - | #include <string.h> |
2 | + | main() |
3 | - | |
3 | + | { |
4 | - | int main() |
4 | + | int array[100], search, c, number; |
5 | - | { |
5 | + | |
6 | - | char Str1[100], Str2[100]; |
6 | + | printf("Enter the number of elements in array: \n"); |
7 | - | int i, j; |
7 | + | scanf("%d",&number); |
8 | - | |
8 | + | |
9 | - | printf("Please Enter the First String : "); |
9 | + | printf("Enter %d numbers : \n", number); |
10 | - | gets(Str1); |
10 | + | for ( c = 0 ; c < number ; c++ ) |
11 | - | |
11 | + | scanf("%d",&array[c]); |
12 | - | printf("Please Enter the Second String : "); |
12 | + | |
13 | - | gets(Str2); |
13 | + | printf("Enter the number to Search : \n"); |
14 | - | |
14 | + | scanf("%d",&search); |
15 | - | i = 0; |
15 | + | |
16 | - | while( Str1[i]!='\0') |
16 | + | for ( c = 0 ; c < number ; c++ ) |
17 | - | { |
17 | + | { |
18 | - | i++; |
18 | + | if ( array[c] == search ) |
19 | - | } |
19 | + | { |
20 | - | |
20 | + | printf("%d - is present at location - %d\n", search, c+1); |
21 | - | j = 0; |
21 | + | break; |
22 | - | while( Str2[j]!='\0') |
22 | + | } |
23 | - | { |
23 | + | } |
24 | - | Str1[i] = Str2[j]; |
24 | + | |
25 | - | i++; |
25 | + | if ( c == number ) |
26 | - | j++; |
26 | + | printf("%d - is not present in array.\n", search); |
27 | - | } |
27 | + | return 0; |
28 | - | Str1[i] = '\0'; |
28 | + | |
29 | - | |
29 | + | } |