Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ #define

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

define c++

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ar array
#define ll long long
#define pb push_back
Comment

#define in cpp

// The #define preprocessor directive creates symbolic constants
#include <iostream>
using namespace std;

#define CONSTANT 2.71828

int main () {
   cout << "Declared constant: " << CONSTANT << endl; 

   return 0;
}
Comment

how to use #define c++

// If there is a command or anything that is too large to type, you use it often
// and wish you could type it faster, you can use #define to define it as
// something else,

#include <bits/stdc++.h>
using namespace std; 

// for example one you can define 'push_back' command for vectors as 'pb'
#define pb push_back
// You can actually give it some values too, like this
#define fo(i,a,b) for(int i = a; i < b; i++)

int main(){
  vector<int> vec;
  // Now do this
  vec.pb(5);
  fo(i,0,10){
    cout << i << endl;
  }
  // Instead of this
  vec.push_back(5);
  for(int i = 0; i < 10; i++){
    cout << i << endl;
  }
}
Comment

C++ #define

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

define c++

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ar array
#define ll long long
#define pb push_back
Comment

#define in cpp

// The #define preprocessor directive creates symbolic constants
#include <iostream>
using namespace std;

#define CONSTANT 2.71828

int main () {
   cout << "Declared constant: " << CONSTANT << endl; 

   return 0;
}
Comment

how to use #define c++

// If there is a command or anything that is too large to type, you use it often
// and wish you could type it faster, you can use #define to define it as
// something else,

#include <bits/stdc++.h>
using namespace std; 

// for example one you can define 'push_back' command for vectors as 'pb'
#define pb push_back
// You can actually give it some values too, like this
#define fo(i,a,b) for(int i = a; i < b; i++)

int main(){
  vector<int> vec;
  // Now do this
  vec.pb(5);
  fo(i,0,10){
    cout << i << endl;
  }
  // Instead of this
  vec.push_back(5);
  for(int i = 0; i < 10; i++){
    cout << i << endl;
  }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ pre-processor instructions 
Cpp :: pointer cpp 
Cpp :: factorial in c++ using recursion 
Cpp :: how to concatenate two vectors in c++ 
Cpp :: find a number in vector c++ 
Cpp :: vector iterating in c++ 
Cpp :: factorial of large number 
Cpp :: set size in c++ 
Cpp :: hashmap c++ 
Cpp :: long pi in c++ 
Cpp :: c++ initialise array 
Cpp :: how to have a queue as a parameter in c++ 
Cpp :: c++ recursion 
Cpp :: online ide c++ 
Cpp :: changing values of mat in opencv c++ 
Cpp :: c++ std string to float 
Cpp :: google test assert stdout 
Cpp :: resharper fold if statement 
Cpp :: power in c++ 
Cpp :: how to format big numbers with commas in c++ 
Cpp :: how to use for c++ 
Cpp :: c++ compare type 
Cpp :: std::map get all keys 
Cpp :: unordered_map c++ 
Cpp :: delete c++ 
Cpp :: for_each c++ 
Cpp :: fractional knapsack problem 
Cpp :: long long vs long long int 
Cpp :: An Array declaration by initializing elements in C++ 
Cpp :: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =