read an array and search an element

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

640


Are global variables static in c?

660


What are structures and unions? State differencves between them.

600


What is an operator?

649


Is c still used?

589






What are the application of c?

634


What is structure pointer in c?

562


What is a floating point in c?

588


How can I write a function analogous to scanf?

642


What does printf does?

727


What is calloc in c?

650


What are the advantages of using Unions?

637


If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..

1576


in linking some of os executables are linking name some of them

1644


What are linker error?

604