1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nekit [7.7K]
3 years ago
13

"Write a generic C++ function" that takes an array of generic elements and a scalar of the same type as the array elements. The

type of the array elements and the scalar is the generic parameter. The function must search the given array for the given scalar and return the subscript of the scalar in the array. If the scalar is not in the array, the function must return –1. Test the function for int and float types.
Computers and Technology
1 answer:
Alex787 [66]3 years ago
6 0

Answer:

#include<iostream>

using namespace std;

template <class myType>

int generic(myType *a, myType b)

{

int i;

for(i=0;a[i]!=-1;i++)

{

if( b == a[i])

return i;

}

return -1;

}

int main()

{

int a[]={1,2,3,4,5,6,7,8,-1};

float b[]={1.1,2.1,3.1,4.1 ,5.1,6.1,7.1,-1};

if(generic(a,5)>0)

{

cout<<" 5 is foundin int at index "<<generic(a,5)<<endl;

}

else

{

cout<<" 5 notfound "<<endl;

}

if(generic(b,(float)5.1)>0)

{

cout<<" 5.1 isfound in float at index "<<generic(a,5)<<endl;

}

else

{

cout<<" 5.1 notfound "<<endl;

}

system("pause");

}

/*

sample output

5 is found in int at index 4

5.1 is found in float at index 4

*/

You might be interested in
Question 5 / 15
erastova [34]

The value that would be returned based on the formula [=COUNTIF(A43:A47, "NP*")] in cell A49 is 4.

Microsoft Excel can be defined as a software application that is designed and developed by Microsoft Inc., so as to avail its end users the ability to analyze and visualize spreadsheet documents.

In Microsoft Excel, there are different types of functions (predefined formulas) and these include:

  • Sum function
  • Average function
  • Minimum function
  • Maximum function
  • Count function

A count function is typically used to to calculate the number of entries in a cell or number field that meets a specific (predefined) value set by an end user.

In this scenario, "NP*" is the specific (predefined) value that was set and as such the value that would be returned based on the formula in cell A49 is 4 because A43, A44, A45 and A46 contain the value "NP."

Read more on Excel formula here: brainly.com/question/25219289

7 0
2 years ago
Read 2 more answers
How many residues separate amino acids that are stabilized by hydrogen bonds in α helices?.
irina [24]

The numbers of residues separate amino acids that are stabilized by hydrogen bonds in α helices is  3.6 amino acid residues.

<h3>Why are amino acids called residues?</h3>

The  Amino acids are known to be compounds that are said to be called residues if there is  two or more amino acids that are known to be bond with each other.

Note that the amino group on one amino acid is one that tends to interacts with the carboxyl group and as such  form a peptide bond.

Therefore, The numbers of residues separate amino acids that are stabilized by hydrogen bonds in α helices is  3.6 amino acid residues.

Learn more about amino acids from

brainly.com/question/2526971

#SPJ1

5 0
2 years ago
Using your favorite imperative language, give an example of each of the following. (a) A lexical error, detected by the scanner
Travka [436]

Explanation:

a. int foo+; (foo+ is an invalid identifier because + is not a valid char in identifiers)

b. foo int; (Syntax error is any error where the syntax is invalid - either due to misplacement of words, bad spelling, missing semicolons etc.)

c. Static semantic error are logical errors. for e.g passing float as index of an array - arr[1.5] should be a SSE.

d. I think exceptions like NullReferenceException might be an example of DME. Not completely sure but in covariant returns that raise an exception at compile time (in some languages) might also come in this category. Also, passing the wrong type of object in another object (like passing a Cat in a Person object at runtime might qualify for DME.) Simplest example would be trying to access an index that is out of bounds of the array.

8 0
3 years ago
How fast is a backwards long jump in Super Mario 64?
Kamila [148]

Answer:

I honestly don't know if you're being serious or not as this was a popular thing a few years ago, there are a few videos on yt, one particularly from 2008 that answers your question pretty well.

Clipping through a loading area requires at least 400 speed. But if you're just interested in the usual speed, there are multiple glitches to make him go faster than his usual x3.5 increased running speed (which is the speed you get at the LEAST when BLJing) but it seems the average is  -200. I've seen people get up to -900 though, so.

Basically, it can vary. In a very specific area he can get max momentum of -9373, which is probably the fastest even though it's against a wall.

6 0
3 years ago
You can not give an exact size for a height for column width true or false
GalinKa [24]

Answer:

~false~

Explanation:

5 0
3 years ago
Other questions:
  • Which innovation allowed for the mass production of goods? A. Cotton gin B. Sewing machine C. Industrial lubricator D. Interchan
    6·1 answer
  • _____ is when network managers deal with network breakdowns and immediate problems instead of performing tasks according to a we
    9·1 answer
  • What type of program would use to create a personal budget?
    14·1 answer
  • Can someone tell me how to get all A's with no effort?
    5·1 answer
  • What is the difference between operating systems and application software?
    6·2 answers
  • Upgrading only the motherboard will give some performance improvement to a computer system. Why would the improvement be limited
    14·1 answer
  • i set up an account and paid the yearly fee, now it's asking me to join. i've tried to log in and brainly isn't accepting my ema
    8·1 answer
  • why is there a need of properly interpreting teacher's/manufacturer's specifications before operating any food processing equipm
    9·1 answer
  • Which type of protocol allows for a secure data transmission using encryption methods?
    7·1 answer
  • Look at the picture ​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!