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

IS Doon college of Engn.. has good faculty

1 Answers  


How can I call fortran?

0 Answers  


Explain void pointer?

0 Answers  


write a program to generate 1st n fibonacci prime number

2 Answers  


an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational

0 Answers  


How does selection sort work in c?

0 Answers  


What is malloc and calloc?

0 Answers  


What is putchar() function?

0 Answers  


write a function to swap an array a[5] elements like a[0] as a[5],a[1] as a[4],....a[5] as a[0].without using more than one loop and use one array not to use temp array?

1 Answers   Zensar,


Who invented bcpl language?

0 Answers  


C program to read the integer and calculate sum and average using single dimensional array

0 Answers  


Which function in C can be used to append a string to another string?

0 Answers  


Categories