Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
Concept Notes and Resources
Concept Learning Code Sheets

#include directive – Preprocessor for header inclusion #4572

Understanding the purpose of include preprocessor

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout<<sqrt(25)<<endl;
return 0;
}

#define directive – Preprocessor for Names to constant replacement #4580

Understanding the purpose of #define pre-processor directive.

#include <iostream>
using namespace std;
#define PI 3.1416
#define R 5
int main()
{
double area=PI*R*R;
double circum=2*PI*R;
cout<<"Area of circle with radius "<<R
<<" = "<<area<<endl;
cout<<"Circumference of circle with radius "<<R
<<" = "<<circum<<endl;
return 0;
}

#define directive as Macros Expressions #4585

Understanding the purpose of #define pre-processor directive to be used as macros or use of replacement action for expressions

#include <iostream>
using namespace std;
#define velocity(u,a,t) u+a*t
int main()
{
int v=velocity(5,2,3);
cout<<v<<endl;
return 0;
}

#define Macros Nesting #4587

Understanding how #define macros can be nested (use of one macros expression as a part of another macros expression)

#include <iostream>
using namespace std;
#define SI(p,r,t) p*r*t/100
#define AMT(p,r,t) p+SI(p,r,t)
int main()
{
int p=203,r=5,t=2 ;
cout<<"Principal = "<<p<<endl;
cout<<"Rate = "<<r<<endl;
cout<<"Time = "<<t<<endl;
cout<<"Simple Interest = "<<SI(p,r,t)<<endl;
cout<<"Amount = "<<AMT(p,r,t)<<endl;
return 0;
}


Quizzes

Concept Notes:1  Code Sheets:4  Quizzes:1
Back