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

write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?

1 Answers  


Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...

1 Answers  


write a program to convert temperature from fa height into celcius and vise versa,use modular programming

0 Answers   Jomo Kenyatta University,


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

0 Answers   Jomo Kenyatta University,


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

0 Answers   ABC, Guidance Software,






Definition of priority queue was given. We have to implement the priority queue using array of pointers with the priorities given in the range 1..n. The array could be accessed using the variable top. The list corresponding to the array elements contains the items having the priority as the array index. Adding an item would require changing the value of top if it has higher priority than top. Extracting an item would require deleting the first element from the corresponding queue. The following class was given: class PriorityQueue { int *Data[100]; int top; public: void put(int item, int priority); // inserts the item with the given priority. int get(int priority); // extract the element with the given priority. int count(); // returns the total elements in the priority queue. int isEmpty(); // check whether the priority queue is empty or not. }; We had to implement all these class functions.

0 Answers   Nagarro, Wollega University,


Perform the functionality of 2-D array through 1-D array and in it the functions to be performed were: (1) Display the array in 2-D format (2) Display a particular element (3) Display a particular row (4) Display a particular column

1 Answers   Nagarro,


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

5 Answers   Satyam,


A research student is given a singly-linked list. Each node of the list has a color, which is either “Black” or “White”. He must find if there are more black nodes than white nodes, or vice versa. His advisor gives him 5,000Rs to buy a computer to do the work. He goes to the computer store and finds a slightly defective computer which costs a mere 3,000Rs. This computer has the small problem of not being able to do arithmetic. This means that he cannot use a counter to count the nodes in the list to determine the majority color. The computer is otherwise fully functional. He has the evil idea that he could buy the defective computer and somehow use it to do his work, so that he can use the rest of the money on enjoyment. Show how he can accomplish this amazing task. Write code for an algorithm called ‘findMajorityColor’ which takes a singly-linked list, L, with n nodes and returns the majority color among nodes of L. This algorithm should have the same asymptotic running time as counting the nodes (O(n)). Note: No arithmetic is allowed.

2 Answers  


Seat Reservation prog for the theatre. Write a function for seat allocation for the movie tickets. Total no of seats available are 200. 20 in each row. Each row is referred by the Character, "A" for the first row and 'J' for the last. And each seat in a row is represented by the no. 1-20. So seat in diffrent rows would be represented as A1,A2....;B1,B2.....;........J1,J2... Each cell in the table represent either 0 or 1. 0 rep would seat is available , 1 would represent seat is reserved. Booking should start from the last row (J) to the first row(A). At the max 20 seats can be booked at a time. if seats are available, then print all the seat nos like "B2" i.e (2 row, 3 col) otherwise Print "Seats are not available." and we must book consecutive seats only.

1 Answers   Nagarro,


What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }

5 Answers   Impetus,


write a program using virtual function to find the transposing of a square matrix?

0 Answers  


Categories