Structure of the Problem Requirements
In Programming there are many cases when you declare same data types variables many time in your program. Every time when you declare a variable with its datatypes reduce the readability and increase your keystrokes. Typedef is a function in which you declare the datatypes with its name (typedef name) and next time you can use that typedef name in your program everywhere. For better understanding we first declare five unsigned short integers and after this used typedef and declare five long int with typedef . Here is the source code of this problem which help you in better understanding.
Source Code
#include<iostream>
using namespace std;
typedef long int L;
int main ()
{
unsigned short int a =1; // Not good to declare every time
unsigned short int b =2;
unsigned short int c =3;
unsigned short int d =4;
unsigned short int e =5;
L ab = 22; // declare with typedef increase the readability of the code
L bc = 34;
L cd = 32;
L de = 12;
L ef = 234;
cout<<" typedef is Used Save Kepstokes ! \n ";
return 0;
}
Output of the Program
0 comments:
Post a Comment