Ubuntu is a Linux distribution based on Debian mostly composed of free and open-source software. Ubuntu is officially released in three editions: Desktop, Server, and Core for Internet of things devices and robots. All the editions can run on the computer alone, or in a virtual machine. Wikipedia
Initial release date: 20 October 2004
Developed by: Canonical
License: Free software + some proprietary device drivers
Latest release: Ubuntu 20.04 / 23 April 2020 (2 months ago)
Developer: Canonical Ltd.
gcc
GNU C Compiler ( gcc ) is a compiler in Linux which is used to compile C programs. It compiles files with extension “.c”.
g++
GNU C++ Compiler ( g++ ) is a compiler in Linux which is used to compile C++ programs. It compiles both files with extension .c and .cpp as C++ files.
Step 1. Open terminal.
Step 2. Type command to install gcc or g++ complier:
$ sudo apt-get install build-essential
Terminal helps us to share all things which we have seen in terminal:
I have copied all things which we have seen in our session and shared to you.
sdbhosale@sdbhosale-Inspiron-N5010:~$ pwd
/home/sdbhosale
sdbhosale@sdbhosale-Inspiron-N5010:~$ cd Downloads
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads$ pwd
/home/sdbhosale/Downloads
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads$ ls
old_Downloads
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads$ mkdir tyab
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads$ ls
old_Downloads tyab
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads$ cd tyab
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ pwd
/home/sdbhosale/Downloads/tyab
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 1.cpp
#include<iostream.h>
void main()
{
cout<<"\n Welcome";
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 1.cpp
#include<iostream.h>
void main()
{
cout<<"\n Welcome\n\n";
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 1.cpp
1.cpp:1:21: fatal error: iostream.h: No such file or directory
#include<iostream.h>
^
compilation terminated.
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 1.cpp
1.cpp:2:11: error: ‘::main’ must return ‘int’
void main()
^
1.cpp: In function ‘int main()’:
1.cpp:4:1: error: ‘cout’ was not declared in this scope
cout<<"\n Welcome\n\n";
^
1.cpp:4:1: note: suggested alternative:
In file included from 1.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 1.cpp
1.cpp:2:11: error: ‘::main’ must return ‘int’
void main()
^
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp a.out
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./a.out
Welcome
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 2.cpp
/*A C++ program to perform addition of two numbers*/
#include<iostream>
main()
{
int a,b,c;
cout<<"\n Please enter a=";
cin>>a;
cout<<"\n Please enter b=";
cin>>b;
c=a+b;
cout<<"\n Addition of a and b="<<c;
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 2.cpp
2.cpp: In function ‘int main()’:
2.cpp:6:1: error: ‘cout’ was not declared in this scope
cout<<"\n Please enter a=";
^
2.cpp:6:1: note: suggested alternative:
In file included from 2.cpp:2:0:
/usr/include/c++/4.8/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^
2.cpp:7:1: error: ‘cin’ was not declared in this scope
cin>>a;
^
2.cpp:7:1: note: suggested alternative:
In file included from 2.cpp:2:0:
/usr/include/c++/4.8/iostream:60:18: note: ‘std::cin’
extern istream cin; /// Linked to standard input
^
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 2.cpp
/*A C++ program to perform addition of two numbers*/
#include<iostream>
main()
{
int a,b,c;
std::cout<<"\n Please enter a=";
std::cin>>a;
std::cout<<"\n Please enter b=";
std::cin>>b;
c=a+b;
std::cout<<"\n Addition of a and b="<<c;
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 2.cpp
/*A C++ program to perform addition of two numbers*/
#include<iostream>
using namespace std;
main()
{
int a,b,c;
cout<<"\n Please enter a=";
cin>>a;
cout<<"\n Please enter b=";
cin>>b;
c=a+b;
cout<<"\n Addition of a and b="<<c;
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp a.out
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./a.out
Please enter a=3
Please enter b=5
Addition of a and b=8sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./a.out
Please enter a=3
Please enter b=5
Addition of a and b=8
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 2.cpp
/*A C++ program to perform addition of two numbers*/
#include<iostream>
using namespace std;
main()
{
int a,b,c;
cout<<"\n Please enter a=";
cin>>a;
cout<<"\n Please enter b=";
cin>>b;
c=a+b;
cout<<"\n Addition of a and b="<<c<<"\n";
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./a.out
Please enter a=3
Please enter b=2
Addition of a and b=5
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./a.out
Welcome
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./a.out
Please enter a=3
Please enter b=4
Addition of a and b=7
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp a.out
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o first 1.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp a.out first
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o second 2.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp a.out first second
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./first
Welcome
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./second
Please enter a=1
Please enter b=2
Addition of a and b=3
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp 3.cpp a.out first second third
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
Please enter single character=*
x=*
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=*
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 3.cpp
/*A C++ program to understand single character*/
#include<iostream>
using namespace std;
main()
{
char x='*';
/*cout<<"\n Please enter single character=";
cin>>x;*/
cout<<"\n x="<<x<<endl;
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=*
Yes Logical condition is Truesdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=*
Yes Logical condition is True
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=#
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=#
No! Logical Condition is False
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp 3.cpp a.out first second third
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 3.cpp
/*A C++ program to understand single character*/
#include<iostream>
using namespace std;
main()
{
char x='#';
/*cout<<"\n Please enter single character=";
cin>>x;*/
cout<<"\n x="<<x<<endl;
if(x=='*')
{
cout<<"\n Yes Logical condition is True"<<endl;
}
else
{
cout<<"\n No! Logical Condition is False"<<endl;
}
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cp 3.cpp 4.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp 3.cpp 4.cpp a.out first second third
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ cat 4.cpp
/*A C++ program to understand single character*/
#include<iostream>
using namespace std;
main()
{
char x='#';
/*cout<<"\n Please enter single character=";
cin>>x;*/
cout<<"\n x="<<x<<endl;
if(x=='*')
{
cout<<"\n Yes Logical condition is True"<<endl;
}
else
{
cout<<"\n No! Logical Condition is False"<<endl;
}
}
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ rm 4.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp 3.cpp a.out first second third
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ rm a.out
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ls
1.cpp 2.cpp 3.cpp first second third
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ clear
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=#
Yes Logical condition is True
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
x=*
No! Logical Condition is False
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ nano 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ g++ -o third 3.cpp
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
Please enter single character=*
x=*
Star
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
Please enter single character=#
x=#
hash
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
Please enter single character=@
x=@
at the rate
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$ ./third
Please enter single character=!
x=!
Character is not from star, hash and at the ratesdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$
sdbhosale@sdbhosale-Inspiron-N5010:~/Downloads/tyab$
Facebook Video
No comments:
Post a Comment