Write a program using one dimensional array that searches a
number and display the number of times it occurs on the list
of 12 input values.
Sample input/output dialogue:
Enter 12 values:
13 15 20 13 30 35 40 16 18 20 18 20
Enter number to search: 20
Occurences: 3

Answer Posted / sreejesh1987

#include<stdio.h>
#include<conio.h>
void main()
{
int i,flag=0;
float s,a[4];
clrscr();
printf("Enter Twelve numbers:");
for(i=0;i<12;i++)
scanf("%f",&a[i]);

printf("Enter a number to search:");
scanf("%f",&s);

for(i=0;i<12;i++)
if(a[i]==s)
flag++;


printf("\nOccurances:%d",flag);

getch();
}

Is This Answer Correct ?    16 Yes 32 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

3958


create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

2220


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

3440


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2065


write a program that reverses the input number of n.Formulate an equation to come up with the answer.

7041






U hv to enter a range from a and b and search hw many no. of times a pattern n. occurs between the range a and b. Eg :i/p:enter range :0 100 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 0 to 100:1 Eg :i/p:enter range :100 1000 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 100 to 1000: (in this 13,113,131,132,133…139,213,313,…913 all these will be counted)

2125


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

7344


Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)

4453


1+1/2!+1/3!+...+1/n!

1945


can you please write a program for deadlock that can detect deadlock and to prevent deadlock.

2746


develop a program to calculate and print body mass index for 200 employees

2216


how to write a program that opens a file and display in reverse order?

2567


write a program using 2 D that searches a number and display the number of items 12 inputs values input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20 enter no. to search : 20

3368


write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used

4310


Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

2198