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

When should you not use a type cast?

0 Answers  


Explain which function in c can be used to append a string to another string?

0 Answers  


why programming language C is still used in operating system's kernel??

1 Answers   Wipro,


How can you check to see whether a symbol is defined?

0 Answers  


how to determine the complexity of an algorithm as log(n)

1 Answers   Google,






How many levels of indirection in pointers can you have in a single declaration?

0 Answers   Agilent, ZS Associates,


what is the output for this question: main() { int i=1; printf("%d%d%d",i,i++,++i); }

9 Answers  


What does s c mean on snapchat?

0 Answers  


wat is the meaning of c?

9 Answers   CTS, IBM, Wipro,


int a=2,b=3,c=4; printf("a=%d,b=%d\n",a,b,c); what is the o/p?

6 Answers   Verifone,


Define Array of pointers.

0 Answers  


write a 'c' program to sum the number of integer values

8 Answers  


Categories