Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ preprocessor operations

//INCLUDING BUILT-IN LIBRARIES...
#include <iostream>
#include <stdlib.h>
//PRE-DEFINE CONSTANT VALUES...
#define MAXNUM -12    //defining an integer
#define PI 3.1415     //defining a float
#define END "

		Program has ended!!
"   //defining a string
//PRE-DEFINING CONSTANT OPERATIONS...
#define ADD(a, b, c) (a + b + c)    //Operation that will add its 3 parameters

using namespace std;

int main(){
    //using other definitions to check if the current device is Windows or UNIX
    #ifdef _WIN32  
        cout<<"Windows Operating System Detected"<<endl;
    #elif __unix__
        cout<<"UNIX Operating System Detected"<<endl;
    #else
        cout<<"Operating System could NOT be identified!"<<endl;
    #endif
    
    cout<<endl<<"Using pre-defined values and operations: "<<endl;
    cout<<" • MAXNUM: "<<MAXNUM<<endl;       //using pre-defined integer
    cout<<" • PI: "<<PI<<endl;               //using pre-defined float
    cout<<" • ADD(): "<<ADD(2,5,99.5)<<endl;   //using pre-defined function

    cout<<END;    //using pre-defined string
    return 0;
}
Comment

c++ preprocessor commands

#include <iostream>
using namespace std;

#define PI 3.14159

int main () {
   cout << "Value of PI :" << PI << endl; 

   return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: delete c++ 
Cpp :: compare function in c++ 
Cpp :: string copy in cpp 
Cpp :: c++ string to char* 
Cpp :: stl map remove item 
Cpp :: c++ string concatenation 
Cpp :: c++ create function pointer 
Cpp :: merge sort in descending order c++ 
Cpp :: how to rotate a matrix 90 degrees clockwise 
Cpp :: abs in c++ used for 
Cpp :: not c++ 
Cpp :: long long vs long long int 
Cpp :: c++ char 
Cpp :: c++ string example 
Cpp :: how to compile c++ code with g+ 
Cpp :: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope 
Cpp :: read a file line by line c++ struct site:stackoverflow.com 
Cpp :: Write a C++ program to Computing Mean and Median Using Arrays 
Cpp :: object inside class c++ 
Cpp :: time_t c++ stack overflow 
Cpp :: log base 10 c+_+ 
Cpp :: kruskal algorithm 
Cpp :: sort an array using stl 
Cpp :: c++ text between substrings 
Cpp :: check whether kth bit is 1 
Cpp :: C++ Automatic Conversion from double to int 
Cpp :: c++ sort numbers by magnitude/absolute value 
Cpp :: c/c++ pointers 
Cpp :: c++ insertion in astack 
Cpp :: cannot access base class members 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =