Answer to Question #193417 in C++ for ram@2002

Question #193417

The list of random numbers stored in an integer and float array. Perform search operation to find the search number is present or not from an array using templates concept.

* Print - Element Found or Element Not Found

input:

5

15

28

36

44

50

36

Output :

36

Element Found


1
Expert's answer
2021-05-14T23:53:04-0400
#include <iostream>

using namespace std;

int main()
{
    int a[50];
    float b[50],n;
    srand(time(0));
    for (int i = 0; i < 50; i++)
        a[i] = 1 + rand() % 5;
    for (int i = 0; i < 50; i++)
        b[i] = 1 + (rand() % 5)/10;
    cout << "Enter num: "<< endl;
    cin>>n;
    
    int count=0;
    for (int i=0; i<50; ++i)
        if (a[i]==n|| b[i]==n)
            count++;
    if (count==0)
        cout<<"Element  Found";
    else
        cout <<"Element not Found";
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog