Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Run a C++ Program Without Namespace?

Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 02 Nov, 2022
Improve Article
Save Article
Like Article

Prerequisite: Namespace in C++

If we want to run a program without using a namespace, we have to the std keyword along with the space resolution operator (::)  in every printing line and variable declaration,

For example, 

std::cout<<"geeksforgeeks";

Example:

C++




// C++ Program without the use of using namespace std;
#include <iostream>
#include <string>
  
int main()
{
  
    std::cout << "geeksforgeeks";
    return 0;
}


Output

geeksforgeeks

Example:

C++




// C++ Program without the use of using namespace std
#include <bits/stdc++.h>
  
int main()
{
  
    int a = 5;
    int b = 10;
    int c = a + b;
    std::cout << c << std::endl;
    return 0;
}


Output

15
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!