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 :: c++ #include 
Cpp :: how to make window resizable in sdl 
Cpp :: c++ exceptions 
Cpp :: Give an algorithm for finding the ith-to-last node in a singly linked list in which the last node is indicated by a null next reference. 
Cpp :: c++ syntax 
Cpp :: function overriding in c++ 
Cpp :: check even or odd c++ 
Cpp :: string format decimal places c++ 
Cpp :: c++ average vector 
Cpp :: count sort algorithm 
Cpp :: c++ function of find maximum value in an array 
Cpp :: run c++ program mac 
Cpp :: c++ vector 
Cpp :: how to grab each character from a string 
Cpp :: C++ Pi 4 Decimal 
Cpp :: how to get euler constant in c++ 
Cpp :: reference c++ 
Cpp :: string erase 
Cpp :: c++ unittest in ros 
Cpp :: c++ check that const char* has suffix 
Cpp :: c++ pass ofstream as argument 
Cpp :: C++ Quotient and Remainder 
Cpp :: c++ catch Unhandled exception 
Cpp :: c++ multiline string 
Cpp :: how to use power in c++ 
Cpp :: how to insert in a queue c++ 
Cpp :: insertion overloading in c++ 
Cpp :: even and odd numbers 1 to 100 
Cpp :: linkedlist in c++ 
Cpp :: Round 1 Confusion codechef solution in c++ 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =