My Blog
Articles related to programming, computer science, technology and research.

CPP program to illustrate enumerations

05/03/2017 Categories: Others. No Comments on CPP program to illustrate enumerations

A program to illustrate enumerations. Program is as follows: #include <iostream> using namespace std; int main() { enum direction{left=’l’, right=’r’}; char ch; cout<<“Enter direction (as character): “; cin>>ch; direction d = (direction) ch; switch(d) { case left: { cout<<“Go left”; break; } case right: { cout<<“Go right”; break; } default: { cout<<“Wrong direction”; } } […]

Read the rest of this entry »

CPP program to illustrate scope resolution new and delete operators

05/03/2017 Categories: Others. 2 Comments on CPP program to illustrate scope resolution new and delete operators

A program to illustrate scope resolution, new and delete operators. Program is as follows:

Output for the above program is as follows:

 

Read the rest of this entry »

CPP program to calculate the fare for the passengers travelling in a bus

05/03/2017 Categories: Others. No Comments on CPP program to calculate the fare for the passengers travelling in a bus

Write a Program to calculate the fare for the passengers travelling in a bus. When a Passenger enters the bus, the conductor asks “What distance will you travel?” On knowing distance from passenger (as an approximate integer), the conductor mentions the fare to the passenger according to following criteria: 5KM: Rs.10 5-10KM: Rs.20 10-30KM: Rs.50 […]

Read the rest of this entry »

CPP program to calculate simple interest and compound interest

05/03/2017 Categories: Others. No Comments on CPP program to calculate simple interest and compound interest

A program that computes the simple interest and compound interest payable on principal amount(in Rs.) of loan borrowed by the customer from a bank for a given period of time (in years) at specific rate of interest. Assume that interest is compounded monthly. Program is as follows:

Input and output for the above program […]

Read the rest of this entry »

CPP program to read name of the user and print it back

05/03/2017 Categories: Others. No Comments on CPP program to read name of the user and print it back

A simple program on printing “Hello World” and “Hello Name” where “Name” is the input from the user. Program is as follows:  

Input and output for the above program are as follows:

 

Read the rest of this entry »

CPP program to display basic data type values

20/02/2017 Categories: Others. No Comments on CPP program to display basic data type values

This is a C++ program to read and print basic data type values. The float type value must be corrected to 3 places and double type value must be corrected to 9 decimal places. To make this happen, we used fixed and setprecision available in iomanip header file. Code is as follows:

Input and output for the above program […]

Read the rest of this entry »

CPP program to read three integers and print their sum

20/02/2017 Categories: Others. No Comments on CPP program to read three integers and print their sum

This is a C++ program to read three numbers from user and print the sum of those numbers:

Input and output for the above program are as follows:

 

Read the rest of this entry »

CPP program to print Hello World

20/02/2017 Categories: Others. No Comments on CPP program to print Hello World

This is C++ program to print Hello World! to the stdout (generally console).

Output for the above program is as follows:

 

Read the rest of this entry »
Scroll Up