Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c define

//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

c define

#define SIZE 42
#define MSG "Hello, World!"
Comment

PREVIOUS NEXT
Code Example
Cpp :: find element in vector 
Cpp :: factorial calculator c++ 
Cpp :: c++ reverse string 
Cpp :: tree to array c++ 
Cpp :: print two dimensional array c++ 
Cpp :: automatic legend matlab 
Cpp :: how can we create 4 digit random number in c++ 
Cpp :: C++ Conditions and If Statements 
Cpp :: c++ random generator 
Cpp :: C++ Infinite while loop 
Cpp :: gcc suppress warning inline 
Cpp :: c++ find object in vector by attribute 
Cpp :: cpp ifdef 
Cpp :: c++ program to convert character to ascii 
Cpp :: resize string c++ 
Cpp :: rotate an array of n elements to the right by k steps 
Cpp :: convert all strings in vector to lowercase or uppercase c++ 
Cpp :: c++ shell 
Cpp :: abstraction in cpp 
Cpp :: toString method in c++ using sstream 
Cpp :: uparam(ref) 
Cpp :: c++ string_t to string 
Cpp :: c++ delay 
Cpp :: what is function c++ 
Cpp :: age in days in c++ 
Cpp :: cin does not wait for input 
Cpp :: error uploading arduino code 
Cpp :: time complexity of best sort algorithm 
Cpp :: order 2d array in c++ 
Cpp :: valid parentheses in c++ 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =