Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Header file



Working with switch case



" ; " after loop



Iterative statement



Comment




Array_searching




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int i,n,arr[100],num,found=0; pf("Enter the element number: "); scanf("%d",&n); //taking array element pf("\nEnter array element: "); for(i=0;i < n;i++) scanf("%d",&arr[i]); //taking searching input number pf("\nEnter the searching number: "); scanf("%d",&num); //searching array for(i=0;i < n;i++) { if(arr[i]==num) { //in the array element where the searching find the program will end found=1; pf("\n%d IS EXISTED at THE POSITION = %d",num,i); break; } } //if the array element is not match with searching number if(found==0) pf("\n%d IS NOT EXISTED IN THE ARRAY.",num); return 0; }
OUTPUT:


© 2018 - All rights reserved