C++ programming examples with solutions Complete C++ Programs | C++ programming tutorials
C++ programming examples |
In these C++ programming examples, I will provide you complete solutions with given problems. First, I will provide you the problem as a question then I will answer that problem. I have discussed many more problems with C++ programming examples using also automata in the programs. First the C++ program then I write the automata of the program. These are the best C++ programming tutorials that you can take to learn the basics of C++ programming. The C++ programs are managed well in these tutorials.
Let's start C++ programming examples.
Write a program that inputs dividend and divisor. It then calculates and
Displays quotient and reminder. C++ programming tutorials
Answer with C++ programming examples
#include<constream.h>// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” input teaken from user “;
}
Void process data ()
{
Cout <<”calculate the dividend and divisor “;
}
Void show data ()
{
Cout << “ display quotient and reminder “ ;
}
Automata of the C++ programs
a b c
a 1’2 = take data from user .
b 2,3 = process on the data
c 3’4 = show data / result
1 is the initial state
4 is the ending state
write a program that inputs a three-digit number from the user and displays it in reverse order. For example if the user enters 123’ it displays 321.
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int n;
Int a;
Int b;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the three digit number from the user“;
}
Void process data ()
{
Cout <<”reverse the entered number“;
}
Void show data ()
{
Cout << “displays the reversed number“;
}
Automata of the C++ programs
n a b
n 1’2 = take the inputs from the user .
a 2,3 = process . reverse the numbers taken from the user
b 3’4 = show data / result
1 is the initial state
4 is the ending state
write a program that inputs two numbers and finds whether both are equal and show the result.
Answer C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int x;
Int y;
Int z;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the two numbers from the user “;
}
Void process data ()
{
Cout <<”compare them whether they are equal or not “;
}
Void show data ()
{
Cout << “show the results of the compare numbers “;
}
Automata of the C++ programs
x y z
x 1’2 = take the inputs from the user of two numbers.
y 2,3 = process it . They are equal or not
z 3’4 = show data / result displays
1 is the initial state
4 is the ending state
write a program that inputs two numbers and finds if second number is square of first and displays the result. C++ programming tutorials
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the two different numbers from the user“;
}
Void process data ()
{
Cout <<”calculate the numbers whether it’s the square of the 1st number“;
}
Void show data ()
{
Cout << “print the result on the screen “;
}
Automata of the C++ programs
a b c
a 1’2 = take the two different numbers from the user .
b 2,3 = check the number second is the square of the first number.
c 3’4 = show data / result on the screen.
1 is the initial state
4 is the ending state
write a program that adds two floating point numbers and show on screen. C++ programming tutorials
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the two floating point numbers from the user“;
}
Void process data ()
{
Cout <<”adding the two floating points numbers“;
}
Void show data ()
{
Cout << “show the sum of the floating-point on the screen. “;
}
Automata of the C++ programs
a b c
a 1’2 = take the two floating point numbers from the user.
b 2,3 = process . sum up the floating point numbers.
c 3’4 = show data / show the result on the screen.
1 is the initial state
4 is the ending state
write a program that calculate and print the area of square with given height and width. C++ programming tutorials
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the height and width“;
}
Void process data ()
{
Cout <<”calculate the area of square “;
}
Void show data ()
{
Cout << “print the result on the screen “;
}
Automata of the C++ programs
a b c
a 1’2 = take the height and width from the user .
b 2,3 = process it the area of square
c 3’4 = show data / here show the result of the process.
1 is the initial state
4 is the ending state
write a program that inputs ponds from the user and converts it into kilogram and show the result.
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the ponds from the user.“;
}
Void process data ()
{
Cout <<”converts the ponds into the kilograms“;
}
Void show data ()
{
Cout << “displays the result on the screen. “;
}
Automata of the C++ programs
a b c
a 1’2 = take the ponds digits from the user .
b 2,3 = process .change ponds to the kilograms.
c 3’4 = show data / displays the result.
1 is the initial state
4 is the ending state
write a program that inputs two times in hh.mm.ss format adds both times and displays the total times.
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs take in form hh.mm.ss two times from the user“;
}
Void process data ()
{
Cout <<”adds the hh.mm.ss both inputs“;
}
Void show data ()
{
Cout << “displays the total time “;
}
Automata of the C++ programs
a b c
a 1’2 = take the inputs in the form of hh.mm.ss two times from user. .
b 2,3 = process . adding the inputs taken from user.
c 3’4 = show data / displays the total times result.
1 is the initial state
4 is the ending state
write a program that inputs marks obtained by a student in five subjects. It then calculates and displays the total marks and percentage.
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the five subjects marks “;
}
Void process data ()
{
Cout <<”calculate the total marks and percentage of the students.“;
}
Void show data ()
{
Cout << “displays the result on the print screen“;
}
Automata of the C++ programs
a b c
a 1’2 = take numbers of five subeject of the students .
b 2,3 = process . calculates the total marks and percentage of the students
c 3’4 = show data / displays the out put.
1 is the initial state
4 is the ending state
write a program that inputs two times in hh.mm.ss format adds both times and displays the total times.
Answer with C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs take in form hh.mm.ss two times from the user“;
}
Void process data ()
{
Cout <<”adds the hh.mm.ss both inputs“;
}
Void show data ()
{
Cout << “displays the total time “;
}
Automata of the C++ programs
a b c
a 1’2 = take the inputs in the form of hh.mm.ss two times from user. .
b 2,3 = process . adding the inputs taken from user.
c 3’4 = show data / displays the total times result.
1 is the initial state
4 is the ending state
write a program that inputs marks obtained by a student in five subjects. It then calculates and displays the total marks and percentage.
Answer C++ programming examples
#include<iostream.h>#include<conio.h>
// Global variables
Int a;
Int b;
Int c;
Void take data ();
Void process data ();
Void show data ();
Void main ()
{
Take data ();
Process data ();
Show data ();
}
Void take data ()
{
Cout <<” inputs the five subjects marks “;
}
Void process data ()
{
Cout <<”calculate the total marks and percentage of the students.“;
}
Void show data ()
{
Cout << “displays the result on the print screen“;
}
Automata of the C++ programs
a b c
a 1’2 = take numbers of five subjects of the students.
b 2,3 = process . calculates the total marks and percentage of the students
c 3’4 = show data/displays the output.
1 is the initial state
4 is the ending state
No comments
Note: Only a member of this blog may post a comment.