Week days example using Enumeration in C++


Example Program:

Here is the simple program for printing the data type basic example using Template in C++.

Source Code

#include<iostream>
using namespace std;
template<class T>
T Large(T num1,T num2)
{
  return (num1>num2)?num1:num2;
}
int main()
{
  int int1,int2;
  float float1,float2;
  char char1,char2;
  cout<<"Enter two integers:\n";
  cin>>int1>>int2;
  cout<<Large(int1, int2)<<" is larger."<<endl;
  cout<<"\nEnter two floating-point numbers:\n";
  cin>>float1>>float2;
  cout<<Large(float1, float2)<<" is larger."<<endl;
  cout<<"\nEnter two characters:\n";
  cin>>char1>>char2;
  cout<<Large(char1, char2)<<" has larger ASCII value.";
  return 0;
}
To download raw file Click Here

Output

Enter two integers:
12
23
23 is larger.

Enter two floating-point numbers:
23.2
45.4
45.4 is larger.

Enter two characters:
c
a
c has larger 
ASCII value. 98
98

Basic Programs


Flow Control

IF Statement Examples


Switch Case


Goto Statement


Break and Continue


While Loop


Do While Loop


For Loop


Friend Function in C++


String Examples


Array Examples


Structure Examples


Structure & Pointer Examples


Structure & Functions Examples


Enumeration Examples


Template Examples


Functions


Inheritance Examples

Hierarchical Inheritance


Hybrid Inheritance


Multilevel Inheritance


Multiple Inheritance


Single Level Inheritance


Class and Objects

Constructor Example


Destructor Example


Operator Overloading Example


Operator and Function Example


List of Programs


Pointer Examples


Memory Management Examples


Pointers and Arrays


Virtual Function Examples



Learn All in Tamil © Designed & Developed By Tutor Joes