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

What is the use of header files?

0 Answers  


what is difference between declaring the pointer as int and char in c language?

3 Answers  


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

0 Answers  


How to reverse a string using a recursive function, without swapping or using an extra memory?

31 Answers   Cisco, Mind Tree, Motorola, Ophio, Sony, TCS, Wipro,


What is the use of printf() and scanf() functions?

0 Answers  






Once I have used freopen, how can I get the original stdout (or stdin) back?

0 Answers  


Explain what is #line used for?

0 Answers  


What is the explanation for cyclic nature of data types in c?

0 Answers  


how to use enum datatype?Please explain me?

3 Answers   Excel,


program to find the magic square

1 Answers   Infosys,


what would be the output of the follwing struct st { char name[20]; int i; float f; }; main() { struct st emp = {"forum"}; printf("%d %f",emp.i,emp.f); }

4 Answers  


Write a program to find the smallest and largest element in a given array in c language

11 Answers   Microsoft, Vembu,


Categories