# C TUTORIAL
# C PROGRAMS
Pointers Examples
➤ Pointer Basic Examples
➤ Dynamic Memory Allocation
➤ Read Write Array with Pointer
➤ Sum Avg of Array with Pointer
➤ Sort Array with Pointer
➤ Search in Array using Pointer
➤ Sum of N Numbers
➤ Largest Number by DMA
Others
➤ C Program Without Main()
➤ Hello World Without ;
➤ Process & Parent Process ID
➤ C Program Without Header File
➤ void main(), main() vs int main()
➤ fork() function in C
➤ Why gets function is dangerous
➤ Undefined reference to sqrt
# C PROGRAMS
Pointers Examples
➤ Pointer Basic Examples
➤ Dynamic Memory Allocation
➤ Read Write Array with Pointer
➤ Sum Avg of Array with Pointer
➤ Sort Array with Pointer
➤ Search in Array using Pointer
➤ Sum of N Numbers
➤ Largest Number by DMA
Others
➤ C Program Without Main()
➤ Hello World Without ;
➤ Process & Parent Process ID
➤ C Program Without Header File
➤ void main(), main() vs int main()
➤ fork() function in C
➤ Why gets function is dangerous
➤ Undefined reference to sqrt
#include<stdio.h> void search(int *x, int *y); int main() { int a[5], n, i; int *pa, *pn; pa = &a[0], pn = &n; printf("Enter array element: "); for (i=0;i<5;i++) { scanf("%d",pa+i); } printf("Enter element for search: "); scanf("%d",pn); search(&a[0],pn); return 0; } void search (int *x, int *y) { int i, f=0; for (i=0;i<5;i++) { if ( *(x+i) == *y) { f=1; break; } else continue; } if (f==1) printf("Found.\n"); else printf("Not found.\n"); }
Output:-
Enter array element: 12
13
14
15
16
Enter element for search: 9
Not found.
Enter array element: 25
32
61
48
91
Enter element for search: 32
Found.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!
Similar C programs on Pointers