C++ Programming Blog

 
 
 

Image

#include <iostream.h>
#include <conio.h>

template <class T>
T findMin(T arr[],int n)
{
    int i;
    T min;
    min=arr[0];
    for(i=0;i<n;i++)
    {
         if(min > arr[i])
        min=arr[i];
    }
    return(min);
}


void main()
{
    clrscr();
    int iarr[5];
    char carr[5];
    double darr[5];

    cout << \"Integer Values \\n\";
    for(int i=0; i < 5; i++)
    {
        cout << \"Enter integer value \"  << i+1 << \" : \";
        cin >> iarr[i];
    }

    cout << \"Character values \\n\";
    for(int j=0; j < 5; j++)
    {
        cout << \"Enter character value \" << j+1 << \" : \";
        cin >> carr[j];
    }


    cout << \"Decimal values \\n\";
    for(int k=0; k < 5; k++)
    {
        cout << \"Enter decimal value \" << k+1 << \" : \";
        cin >> darr[k];
    }
    //calling Generic function...to find minimum value.
    cout<<\"Generic Function to find Minimum from Array\\n\\n\";
    cout<<\"Integer Minimum is : \"<<findMin(iarr,5)<<\"\\n\";
    cout<<\"Character Minimum is : \"<<findMin(carr,5)<<\"\\n\";
    cout<<\"Double Minimum is : \"<<findMin(darr,5)<<\"\\n\";

    getch();
}

    Related Post:
  1. Program to illustrate unary operator increment operator overloading with return type

  2. Program to construct Lagrangess Interpolation Formula from the given distinct data points.

  3. Program to show the projection of 3D objects using Cabinet Oblique Parallel Projection onto xy-plane (i.e. angle=30 deg)

  4. Program to read decimal numbers from a file and convert into hexadecimal

  5. Program of singly link list with different functionalities

  6. Program that prints all the even numbers b/w 0 to 50 ( using while, do-while and for loop )

  7. Program to check whether a word is palindrome or not (using classes & pointers )

  8. Program to convert a Postfix Expression into an Infix Expression

  9. Program to estimate the Differential value of the function using Euler Method

  10. Matrix Addition Program

  11. Program of that provides an example of function overloading

  12. Program that differentiate b/w the variables of the storage class Auto and Static along with global variables

  13. Program that provides an example of functions with default arguments

  14. Program to read a Non-Linear equation in one variable, then evaluate it using Bisection Method and display its kD accurate root

  15. Program simulate the working of Pre-Processor

  16. Program to draw an ellipse using Polynomial Method

  17. Program to read a Non-Linear equation in one variable, then evaluate it using Simple Itrative Method and display its kD accurate root

  18. Program to draw a K-Curve of nth order

  19. Program for electricity board charges calculation

  20. Program to show the projection of 3D objects using Orthographics Projection Parallel onto xy-plane

 
 
Didn't find what you were looking for? Find more on Program that defines template to find minimum value in an array