Q. WAP to search a presence of certain number among different integer entered by user
==> Code goes like this:
#include<stdio.h>
int main()
{
int i,num,a[50],counter,times=0;
printf("Enter size of array: ");
scanf("%d",&num);
printf("Enter %d elements: ",num);
for(i=0;i<num;i++)
{
scanf("%d",&a[i]);
} // Taking values till now
printf("Enter a number to be searched: ");
scanf("%d",&counter); // Taking number to search in array
for(i=0;i<num;i++)
{
if(a[i]==counter)
{
times+=1; //counting the integer which is entered for search
}
}
printf("Number %d is presented for %d times ",counter, times);
return 0;
}
Output:
I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Searching a presence of particular number among number of integers : C Programming
8:49 PM
2020 jan
,
C Programs
,
One dimensional array
,
Searching in array
,
searching in C programming
Edit
0 comments:
Post a Comment