Without
using namespace std C Plus Plus Program to Print Square and Cube
A
big question arises in the previous days was why we use the statement
using
namespace std;
below
the header file in some compilers such as Dev C++ while the other compilers
such as Turbo don’t need such a type of statement.
So,
Today
we will explore what is the reason that we use the
using
namespace std;
and
Is
it possible to program without using this statement.
So,
Let’s start our journey.
Is it
possible to program without using this statement?
Honestly
writing, If you have a scientific mind then you will have probably answer yes
to this question.
You
think that the man who invented this type of code has never to be dependent on
a single statement
using
namespace std;
Yes,
this man has some other option to use instead of
using
namespace std;
The
other option is some difficult and need some extra typing effort i.e
If
you don’t use the
using
namespace std;
Then
you had to be write the
std::cout
std::cin
every
time you write the
cout
cin
Means
instead of using cin simply for input you had to write std::cin
And
instead of using cout simply for output you had to write std::out
So,
that’s a way you can program without.
using
namespace std;
Reason
Behind using namespace std
using
namespace std simplify our task. If we write one time,
using
namespace std;
in
our program below header file. Then we don’t need to write the
std::cout
std::cin
every
time. Instead, we will write
cout
cin
for
output and input respectively. If we have used the
using
namespace std;
below
header file.
Without
using namespace std C Plus Plus Program to Print Square and Cube
Program Code
#include<iostream>
int
main()
{
int i,j,k,m;
std::cout<<"Your square
and cubes\n";
std::cout<<"Integers\t\tSquare\t\t\tCube\n";
for(i=0;i<=10;i++)
{
m=i;
j=i*i;
k=i*i*i;
std::cout<<m<<"\t\t\t"<<j<<"\t\t\t"<<k<<"\n";
}
return
0;
}
Without
using namespace std C Plus Plus Program to Print Square and Cube
Program
Output
The
.exe file of this program generate the following result when we have run it.
Clearly,
you can see it, that this program had print the square and cubes of the numbers
from 1 to 10.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Thank
You !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Post a Comment
Feel Free to Comment Us