read an array and search an element



read an array and search an element..

Answer / meera

#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],i,j,n,key,count=0;
clrscr();
printf("Enter the no.of elements:");
scanf("%d",&n);
printf("Enter the numbers:");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("enter the number to be searched:");
scanf("%d",&key);
for(i=0;i<n;i++)
{
if a[i]==key
(
count++;
printf("\nThe number %d is present",key);
}
}
printf("number of occurance is %d",count);
getch();
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

Are c and c++ the same?

0 Answers  


program to find a smallest number in an array

15 Answers   Microsoft, Sony,


Disadvantages of C language.

0 Answers   Impetus,


What is pointer in c?

0 Answers  


Explain what is the purpose of "extern" keyword in a function declaration?

0 Answers  






What is an object?

5 Answers  


How do you redirect a standard stream?

0 Answers  


What are local and global variables?

3 Answers  


Can we compile a program without main() function?

0 Answers  


how to print this pyramid * * * * * * * * * * * * *

2 Answers  


how to find the kth smallest element in the given list of array elemnts.

8 Answers   Silicon,


Why should I prototype a function?

0 Answers  


Categories