12.1

Write a function template for finding the minimum value contained in an array.

Answer

OUTPUT

minimum value = 1 of array(5,7,3,1,8)
minimum value = 0.501 of array(1.2,1.5,2.3,1,0.501)

12.2

Write a class template to represent a generic vector. Include member functions to perform the following tasks:

  • (a) To create the vector
  • (b) To modify the value of a given element
  • (c) To multiply by a scalar value
  • (d) To display the vector in the following form (10, 20, 30 …)
Answer

OUTPUT

enter size of vector : 4

enter 4 elements one by one :

4    3    2    5

Now contents :

p[4] = ( 4 , 3 , 2 , 5)

to multiply this vector by a scalar quantity enter this scalar quantity : 3

Now contents :

p[4] = ( 12 , 9 , 6 , 15)

to edit a given element enter position of the element : 2

Now enter new value of 2th element : 222

Now new contents :

p[4] = ( 12 , 222 , 6 , 15)

to delete an element enter position of the element :3

New contents :

p[3] = ( 12 , 222 , 15)


Next Previous