Sunday, April 9, 2023

find a number is exists or not in an arrey

 //find a number is exists or not in an arrey 

#include "stdio.h"

int main (){

int arr[2000],i,n,elements;

printf ("enter the size of arrey : ");

scanf ("%i",&n);

printf ("enter all %d elements in the arrey :",n);

for (i=0;i<n;i++){

scanf ("%i",&arr[i]);

}

printf("enter the elements that you want to find within an arrey :\n");

scanf ("%i",&elements);

for (i=0;i<n;i++){

if (elements==arr[i]){

printf ("I find %d at the position %i\n",elements,i+1);

return 0;

}

}

printf ("the %d elements not found in the arrey \n ",elements );

return 0;

}

                                output              output               output            output 

enter the size of arrey : 6

enter all 6 elements in the arrey :67

76

78

87

98

89

enter the elements that you want to find within an arrey :

98

I find 98 at the position 5


No comments:

Post a Comment

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...