Answer to Question #193034 in C++ for Ajith M

Question #193034

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


1
Expert's answer
2021-05-21T06:48:59-0400
#include <iostream>


using namespace std;


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