Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c preprocessor operations

//INCLUDING BUILT-IN LIBRARIES...
#include <stdio.h>
#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

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

    printf(END);    //using pre-defined string
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c #define 
Cpp :: Find the biggest element in the array 
Cpp :: factorial calculator c++ 
Cpp :: C++, for-loop over an array array 
Cpp :: c++ squaroot 
Cpp :: convert int to string in c++ 
Cpp :: sort vector c++ 
Cpp :: unordered_map contains key 
Cpp :: c++ vector remove all duplicate elements 
Cpp :: double to float c++ 
Cpp :: demonstrate constructor 
Cpp :: how to say hello world in c++ 
Cpp :: comparing characters of a string in c++ 
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 :: return array of string in function c++ 
Cpp :: C++ :: 
Cpp :: stl function to reverse an array 
Cpp :: prime or not in cpp 
Cpp :: overload array operator cpp 
Cpp :: substring in c++ 
Cpp :: trie code cpp 
Cpp :: Integer Moves codeforces solution 
Cpp :: program to swap max and min in matrix 
Cpp :: string in c++ 
Cpp :: c++ garbage collection 
Cpp :: C++ Quotient and Remainder 
Cpp :: c++ generic pointer 
Cpp :: cpp vector popback 
Cpp :: memset in cpp 
Cpp :: C++ function inside main 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =