Templates C++
Templates C++
Templates C++
h>
#include <conio.h>
void main()
{
clrscr();
int a = 100;
int b = 200;
switch( a )
{
case 100:
cout << "In Outer Switch." << endl;
switch( b )
{
case 200:
cout << "In Inner Switch." <<
endl;
}
}
cout << "Value of a is : " << a << endl;
cout << "Value of b is : " << b << endl;
getch();
}
Output:
In Outer Switch.
In Inner Switch.
Value of a is : 100
Value of b is : 200
include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a, b, max;
max = ( a > b ) ? a : b;
void main()
{
char ch;
clrscr();
cout << " Enter the character ::: ";
cin >> ch;
switch( ch )
{
case 'a' :
case 'A' :
case 'e' :
case 'E' :
case 'i' :
case 'I' :
case 'o' :
case 'O' :
case 'u' :
case 'U' :
cout << " It is a Vowel.";
break;
default :
cout << " It is not a Vowel.";
}
getch();
}
#include <iostream.h>
#include <conio.h>
void main()
{
char op;
int a, b, res;
clrscr();
switch( op )
{
case '+':
res = a + b;
break;
case '-':
res = a - b;
break;
case '*':
res = a * b;
break;
case '/':
res = a / b;
break;
case '%':
res = a % b;
break;
default:
cout << " Wrong operator";
break;
}
cout << "\n" << a << " " << op << " " << b << " = " << res;
getch();
}
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int n;
switch( n )
{
case 1:
cout << "\n Monday";
break;
case 2:
cout << "\n Tuesday";
break;
case 3:
cout << "\n Wednesday";
break;
case 4:
cout << "\n Thursday";
break;
case 5:
cout << "\n Friday";
break;
case 6:
cout << "\n Saturday";
break;
case 7:
cout << "\n Sunday";
break;
default:
cout << "\n Wrong Number.";
break;
}
getch();
}
#include <iostream.h>
#include <conio.h>
void main()
{
char c;
clrscr();
getch();
}
#include <iostream.h>
#include <conio.h>
void main()
{
char c;
clrscr();
cout << " Enter a character ::: ";
cin >> c;
getch();
}
#include <iostream.h>
#include <conio.h>
float Simp_Int();
void main()
{
clrscr();
float si;
si = Simp_Int();
float Simp_Int()
{
float p, r, t, si;
cout << " Enter Principal, Rate and Time : ";
cin >> p >> r >> t;
si = ( p * r * t ) / 100;
return si;
}
#include <iostream.h>
#include <conio.h>
void cube(int*);
void main()
{
clrscr();
int a = 10;
cube(&a);
getch();
}
#include <iostream.h>
#include <conio.h>
main()
{
clrscr();
float radius;
cout << "\n The area of circle is " << area( radius );
getch();
return 0;
}
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
float p, r, t, si;
si = Simp_Int( 2000, 15 );
cout << "\n Simple Interest = " << si;
si = Simp_Int( 2000 );
cout << "\n Simple Interest = " << si;
si = Simp_Int( );
cout << "\n Simple Interest = " << si;
getch();
}
si = ( p * r * t ) / 100;
return si;
}
si = ( p * r * 3 ) / 100;
return si;
}
si = ( p * 10 * 3 ) / 100;
return si;
}
float Simp_Int( )
{
float si;
si = ( 1000 * 10 * 3 ) / 100;
return si;
}
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
float radius, area, circum;
getch();
}
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
struct Book
{
char name[25];
char author[20];
float price;
};
void main()
{
clrscr();
Book b;
cout << "\n Name of the Book ::: " << b.name;
cout << "\n Author of the Book ::: " << b.author;
cout << "\n Price of the Book ::: " << b.price << "\n";
getch();
}
#include <iostream.h>
#include <conio.h>
struct card
{
int number;
Suit suit;
};
void main()
{
clrscr();
card temp, chosen, prize;
int position;
prize = card3;
cout << "Now, where (1, 2, or 3) is the ace of spades ? ::: ";
cin >> position;
switch( position )
{
case 1:
chosen = card1;
break;
case 2:
chosen = card2;
break;
case 3:
chosen = card3;
break;
}
getch();
}
#include <iostream.h>
#include <conio.h>
#define PI 3.14
class Circle
{
float radius;
public:
void setRadius( float r );
float getRadius();
inline float area();
};
void main()
{
clrscr();
Circle c1;
c1.setRadius(10);
float a = c1.area();
cout << "\n Radius : " << c1.getRadius();
cout << "\n Area of Circle : " << a;
getch();
}