• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

GitopsCentral

  • Home
  • Courses
  • Roadmap
  • About
  • Log In
  • Sign Up

How to install C/C++ on ubuntu or kali linux

December 1, 2018 by shaik zillani

 

c is superset of c++

In this blog post I will show you how to install C/C++ programming language on ubuntu or kali linux.

Introduction

C

C is a procedural programming language. It was initially developed by Dennis Ritchie between 1969 and 1973. The main features of C language include low-level access to memory, simple set of keywords, and clean style, these features make C language suitable for system programming like operating system or compiler development.

C++

C++ is a multi-paradigm programming language that supports object-oriented programming (OOP), created by Bjarne Stroustrup in 1983 at Bell Labs.

Difference between C and C++

The major difference between C and C++ is that C is a procedural programming language and does not support classes and objects,. C++ is a combination of both procedural and object oriented programming language; therefore C++ can be called a hybrid language.

C++ is a super-set of C. C++ can run most of C code while C cannot run C++ code.

C/C++-Compilers

You need a compiler which converts the written C/C++ program into machine language (i.e; binary format). C lang will require GNU C Compiler, also known as gcc. C++ will require g++ compiler.

Installation

The below command will install C/C++ and the compilers, GCC & G++

apt-get update
apt-get install build-essentials
apt-get install gcc
apt-get install g++

Executing C-Program

Let’s verify the installation by executing a simple hello, world C program,

#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}

Save the above program in a file and name it as hello.c Now, let’s compile the above program and execute it.


gcc hello.c

This will compile our program & will create a binary called hello.Let’s execute using the command below,


./hello

executing helloworld in c

Executing a C++ Program

#include <iostream>
using namespace std;

int main()
{
cout << "Hello, World!";
return 0;
}

Save above text in a file & save it as hello.cpp& compile it using below command,


g++ -o hello hello.cpp

Similar to gcc, this will also create a binary called <code>hello</code>& the execution is obvious as below,


./hello

executing hello world program using g++ compiler

IDE (Integrated Development Environment)

emacs logo

We have plenty of options for IDE. I would suggest to go for a simple editor like sublime if you are just a beginner. If you are a linux geek & try to explore things in hard-way, then the ultimate option will be emacs.

Please note that any editor for c/c++ programming is fine for getting started. Its just a personal choice. My favorite is emacs — tough to learn, yet an excellent choice for command line lovers.

Please refer to my blog post on how to install emacs on linux.

c c,  c programming,  g++,  gcc,  gnu c compiler,  kali linux,  linux,  ubuntu

Primary Sidebar

en English
ar Arabiczh-CN Chinese (Simplified)nl Dutchen Englishfr Frenchde Germanhi Hindiid Indonesianit Italianja Japanesems Malaypt Portugueseru Russianes Spanishte Telugu

Course Tags

concurrency free go golang

Recent Posts

  • Roadmap to Mastery
  • Increase SSH connection timeout
  • Check Certificate expiry in Kubernetes
  • space invaders in golang
  • creating kubernetes cluster using eksctl
  • Facebook
  • GitHub
  • YouTube

Contact

Navigation

  • goacademy pro

Footer

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter

info@gitopscentral.com


+91 8341443220

© Copyright 2016-2024 gitopscentral · All Rights Reserved ·