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 |
What is the use of header files?
what is difference between declaring the pointer as int and char in c language?
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?
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?
Once I have used freopen, how can I get the original stdout (or stdin) back?
Explain what is #line used for?
What is the explanation for cyclic nature of data types in c?
how to use enum datatype?Please explain me?
program to find the magic square
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); }
Write a program to find the smallest and largest element in a given array in c language