1. /* Write a program to define an enumerated data type Month with name of 12 months.
Assign first month as 1 and display the integer value assigned to the months.*/
#include<iostream>
#include<conio.h>
void main()
{
enum months
{
Janaurary=1,
February,
March,
May,
April,
June,
July,
August,
October,
September,
November,
December,
};
months month1,month2;
month1=Janaurary;
month2=November;
cout<<" Janaurary :"<<month1<<endl;
cout<<" November:"<<month2<<endl;
getch();
}
Output:
2. Program using inline function to calculate the square of a number.
#include <iostream>
#include <conio.h>
inline int square(int n)
{
return(n*n);
}
void main()
{
int number,result;
cout<<"Enter the value of number(n) to be entered:"<<endl;
cin>>number;
result=square(number);
cout<<"The square of given number is :"<<result<<endl;
getch();
}
Output:
}
Output:
Comments
Post a Comment