The Only Place For All Your Computer Solutions!!!

Becoming a computer geek is now a piece of cake.Learn Computer Hacking,Mobile Hacking,Repair Windows,Game Troubleshooting,Computer Hardware Selection,Cracking, Game Reviews,Java,C++ Encoding And Much More!! FOR FREE!!


Use Labels given below for organized navigation of this blog. comes the most used programming language in the world.This post goes out to students learning C++.
Now i have started with this topic because its fairly easy if you know the syntax for declaring a macro.
What is a macro?
I may not be able to give a true definition here,since i m only a student..not a professional..all i can say is that macro is a function defined in pre-processor(i.e #define (name of macro) (body of macro)) that is used in the following way-:
Above I have used '(' instead of '<' due to html encoding problem.I m yet to find its solution. 1)At compile time,the macro functions sticks its body to the place wherever it is called as ill be showing you in the example below. 2)All the variables in the body of macro become global variables automatically. 3)Their is no need for implicit termination of a macro(i.e No semi colon is required in the end) 4)It must be short and simple. Here is an example to calculate the area of a circle using a macro. Note:The comments are put after //.And remove them if You look to run this program

#define area() 3.14*r*r
//Here area() is our macro,3.14*r*r is the body,here 'r' will automatically become global variable.Note that I have not put a semicolon to terminate function.Its not required.
void main()
{ cout<<"Enter Radius of the circle"<<'\n'; cin>>r;
float a=area();
//This is the call.At compile time,compiler will stick the body of macro here only.Simple.
cout<<"The area of the circle is"<< a <<'\n'; getch(); }

Here it is.I have not executed the program till now..but it will work..In case any error creeps in during the run..ill be happy to be informed.
Please do comment.Thank You.


Post a Comment