You are going to learn a programming language called C++ (most heard but not coded often :P).
These are the following requirements for following this video tutorial:
This is a basic level tutorial.
This is a tutorial series on learning C++ programming language.
I am deeply involved with Blockchain technology. So, this is an endeavor to make Developers equipped with the power of coding any applications using C++ 's Object Oriented Programming (OOP) tool.
Additionally in the end of this series, I will be covering some IEEE papers on improving C++ codes' computing performance using some shortcuts.
Installation guide -
This is for Windows & Ubuntu lovers in particular. Run linux subsystem over Windows OS using WSL.
sudo apt-get install g++g++ hello.cpp -o hello.out command & then./hello.out commandThis tutorial covers basic concepts which are very easy to understand.
The questions along with solutions is as follows: -
Question:
Print "Hello World"
Solution:
/*C++ Program to Print "Hello World"*/
#include
int main()
{
std::cout<<"Hello World"<<std::endl;
return 0;
}
Question:
Enter any integer and print that number
Solution:
/*C++ Program to Print Number Entered by User*/
#include
int main()
{
int num;
//input the number
std::cout<<"Enter an integer \n";
std::cin>>num;
// Print the number
std::cout<<"You entered "<<num<<std::endl;
return 0;
}
Question:
Program to add 2 Numbers.
Solution:
/*C++ Program to Add 2 Numbers*/
#include
int main()
{
int a, b, c;
// Enter a
std::cout<<"Enter a: \n";
std::cin>>a;
// Enter b
std::cout<< "Enter b: \n";
std::cin>>b;
c = a + b;
std::cout<<"The addition of "<<a<<" and "<<b<<" is "<<c <<std::endl;
return 0;
}
Question:
Program to calculate Area of Circle.
Solution:
/*C++ Program on Area of Circle*/
#include
int main()
{
int r; // radius of the circle
double area;
std::cout<<"Enter the radius :\n";
std::cin>> r;
// the area
area = 3.14 * r * r;
std::cout<<"The area of the circle: "<< area<<std::endl;
return 0;
}
Question:
Program to find Divisor and Dividend
Solution:
/*C++ Program to find Divisor and Dividend*/
#include
int main()
{
int dividend, divisor, quotient, remainder;
// dividend
std::cout<<"Enter the dividend: \n";
std::cin>>dividend;
// divisor
std::cout<<"Enter the divisor: \n";
std::cin>>divisor;
quotient = dividend/divisor; //quotient
remainder = dividend % divisor; //remainder
std::cout<<"The quotient is "<<quotient<<std::endl;
std::cout<<"The remainder is "<<remainder<<std::endl;
return 0;
}
Question:
Program to convert Celsius and Fahrenheit
Solution:
/*C++ Program to convert Celsius and Fahrenheit*/
#include
int main()
{
float celsius, fahrenheit;
std::cout<<"Enter temperature in Celsius: \n";
std::cin>>celsius;
fahrenheit = celsius * (9.0/5.0) + 32;
std::cout<<"The temperature in Celsius is "<< celsius<<std::endl;
std::cout<<"The temperature in Fahrenheit is "<< fahrenheit<<std::endl;
return 0;
}
Question:
Program to check a leap year
HINT:
(Source)
To determine whether a year is a leap year, follow these steps:
Solution:
/*C++ Program to check a leap year*/
#include
int main()
{
int year;
std::cout<<"Enter a year: \n";
std::cin>>year;
if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0) {
std::cout<<"It is a leap year"<<std::endl;
}
else {
std::cout<<"It is NOT a leap year"<<std::endl;
}
}
else
{
std::cout<<"It is NOT a leap year"<<std::endl;
}
}
else
{
std::cout<<"It is NOT a leap year"<<std::endl;
}
return 0;
}
Question:
Program to Print ASCII value
Solution:
/*C++ Program to Print ASCII value*/
#include
int main()
{
char c;
std::cout<<"Enter a char: \n";
std::cin>>c;
std::cout<<"The ASCII value of "<<c<< " is "<< int(c)<<std::endl;
return 0;
}
Question:
Program to understand Switch statement
Solution:
/*C++ Program to understand Switch*/
#include
int main()
{
int choice;
std::cout<<"Enter an integer number (1-5): \n";
std::cin>>choice;
switch(choice){
case(1): std::cout<<"You entered 1"<<std::endl;
break;
case(2): std::cout<<"You entered 2"<<std::endl;
break;
case(3): std::cout<<"You entered 3"<<std::endl;
break;
case(4): std::cout<<"You entered 4"<<std::endl;
break;
case(5): std::cout<<"You entered 5"<<std::endl;
break;
default:
std::cout<<"Invalid choice."<<std::endl;
break;
}
return 0;
}
Question:
Program to understand If-else
Solution:
/*C++ Program to understand If-else*/
#include
int main()
{
int n;
std::cout<<"Enter an integer: \n";
std::cin>>n;
if(n % 2 == 0){
std::cout<<"The number is EVEN."<<std::endl;
} else {
std::cout<<"The number is ODD."<<std::endl;
}
return 0;
}
Follow the codes in the Tutorial Notebook.
There is no related tutorial as it is the first one in the series.