a program using one dimensional array that searches a number
if it is found on the list of given input numbers given by
the user and locate its exact location in the list..
""EXAMPLE""
enter how many numbers to be inputted: 5
12 14 11 09 30
what number to search: 11
11 IS FOUND IN LOCATION 3

PLZZZ.. ELP ME...

Answers were Sorted based on User's Feedback



a program using one dimensional array that searches a number if it is found on the list of given i..

Answer / mukesh yadav

int i,j,a[5];
printf("enter the numbers");
for(i=1;i<=10;i++)
{
scanf("\n%d",a[i]);
}
printf("what number to search:");
scanf("%d",j);
for(i=1;i<=10,i++)
{
if(j==a[i])
{
printf("FOUND IN LOCATION:",i);
exit(0);
}
}

Is This Answer Correct ?    13 Yes 10 No

a program using one dimensional array that searches a number if it is found on the list of given i..

Answer / fabiha nazmi

#include <stdio.h>
#include <string.h>
int main()
{
int num[10], a,d, s, i;
printf("Enter how many numbers to be inputted: ");
scanf("%d", &d);

for (i=0; i<d; i++)
{
scanf("%d", &num[i]);
}
printf("what number to search: ");
scanf("%d", &s);
for(i=0; i<d; i++)
{
if (s==num[i])
{
printf("%d is found in location %d", s, i+1);
break;
}
else
{
printf("Not found");
break;
}
}

return 0;
}

Is This Answer Correct ?    4 Yes 4 No

a program using one dimensional array that searches a number if it is found on the list of given i..

Answer / fabiha nazmi

#include <stdio.h>
int main()
{
int num[10], a,d, s, i;
printf("Enter how many numbers to be inputted: ");
scanf("%d", &d);

for (i=0; i<d; i++)
{
scanf("%d", &num[i]);
}
printf("what number to search: ");
scanf("%d", &s);
for(i=0; i<d; i++)
{
if (s==num[i])
{
printf("%d is found in location %d", s, i+1);
break;
}
}
return 0;
}

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C++ Code Interview Questions

swap prog

3 Answers   TCS,


find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L

0 Answers  


Write a &#61521;(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.)

0 Answers  


output for printf("printf");

0 Answers  


Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?

2 Answers   ABC, Qatar University,






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

0 Answers   Nagarro,


using repetition structure. Write a c program that will accept five numbers. The program should count and output the total count of even numbers and total count of add numbers.

2 Answers  


How to Split Strings with Regex in Managed C++ Applications?

0 Answers   Microsoft,


what is virtual constroctor ? give an exam for it?-(parimal dhimmar)

2 Answers  


3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

0 Answers  


what is the use of using for loop as "for(;;)"?

5 Answers   Satyam,


solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)

0 Answers  


Categories