Giter Club home page Giter Club logo

cpp-programs-for-students's Introduction

C++ Programs for College Students ⌨️

  • This repository contains essential C++ programs for college students.
  • I recommend compiling the C++ programs using g++ in GNU/Linux.

Installing g++ in Linux

  • Ubuntu: sudo apt install build-essential
  • Fedora: sudo dnf install g++
  • Most distributions bundle gcc and g++ with them by default, so a seperate installation isn't required.

Compiling a CPP program in g++

  • Ensure g++ is installed by running g++ --version command.
  • Open a terminal emulator of your choice.
  • Navigate to the relevant directory using cd command.
  • Optionally, use touch <filename>.cpp command to create a CPP file.
  • Enter g++ filename.cpp to compile the file. Any compilation/syntactical errors in the program will be displayed here.
  • After a successful compilating, an output binary file a.out will be created by default.
  • You can also provide your own custom output name by adding -o flag at the end of g++ command. For example, g++ <filename>.cpp -o <filename>. Now the binary will be created in a custom filename.
  • To run the binary files just type ./a.out or ./binaryname in the terminal.

Writing and compiling Hello World C++ Program

  • You can write this program in any IDE or text editor of choice.

  • Example code:-

/*helloworld.cpp*/

#include<iostream> //header file
using namespace std; //for using cin,cout commands without std:: tags
int main()
{
cout<<"Hello World"<<endl; 
}
  • To create for the output for file we need compile it using a compiler like GCC,etc.
  • Open Terminal in Linux and cd into the file's directory.
  • Type g++ helloworld.cpp or c++ helloworld.cpp and enter this will create an a.out binary file.
  • For creating an output file with cutstom name use g++ helloworld.cpp -o helloworld.
  • Now we can run the binaries using ./a.out or ./helloworld
  • Output in the terminal would be:-
Hello World

cpp-programs-for-students's People

Contributors

kbdharun avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

kbdkdev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.