Hits: 4 (C++ programming Example for Beginners) C++ Program to Store and Display Information Using Structure This program stores the information (name, roll and marks) of 10 students using structures. In this program, a structure, student is created. This structure has three members: name (string), roll (integer) and marks (float). Then, we created a structure array of size 10 to store information of …
Hits: 6 (C++ programming Example for Beginners) C++ Program to Calculate Difference Between Two Time Period Example: Program to Time Difference // Computes time difference of two time period // Time periods are entered by the user #include <iostream> using namespace std; struct TIME { int seconds; int minutes; int hours; }; void computeTimeDifference(struct TIME, …
Hits: 2 (C++ programming Example for Beginners) C++ Program to Add Two Distances (in inch-feet) System Using Structures This program takes two distances (in inch-feet system), adds them and displays the result on the screen. Example: Add Distances Using Structures #include <iostream> using namespace std; struct Distance{ int feet; float inch; }d1 , d2, sum; …
Hits: 19 (C++ programming Example for Beginners) C++ Program to Store Information of a Student in a Structure This program stores the information (name, roll and marks entered by the user) of a student in a structure and displays it on the screen. In this program, a structure(student) is created which contains name, roll and …
Hits: 5 (C++ programming Example for Beginners) C++ Program to Copy Strings In this example, you will learn to copy strings (both string objects and C-style strings). You can simply copy string objects in C++ using = assignment operator. Example 1: Copy String Object #include <iostream> using namespace std; int main(){ string s1, s2; cout << “Enter …
Hits: 2 (C++ programming Example for Beginners) C++ Program to Concatenate Two Strings In this example, you will learn to concatenate (join) two strings (both string objects and C-style strings). You can concatenate two string objects in C++ using + operator. Example 1: Concatenate String Objects #include <iostream> using namespace std; int main(){ string s1, s2, result; …
Hits: 6 (C++ programming Example for Beginners) C++ Program to Find the Length of a String In this example, you will learn to compute the length (size) of a string (both string objects and C-style strings). You can get the length of a string object by using a size() function or a length() function. The size() and length() functions are just synonyms and …
Hits: 4 (C++ programming Example for Beginners) C++ Program to Find the Number of Vowels, Consonants, Digits and White Spaces in a String Example 1: From a C-style string This program takes a C-style string from the user and calculates the number of vowels, consonants, digits and white-spaces. #include <iostream> using namespace std; int main(){ …
Hits: 5 (C++ programming Example for Beginners) C++ Program to Swap Numbers in Cyclic Order Using Call by Reference This program takes three integers from the user and swaps them in cyclic order using pointers. Three variables entered by the user are stored in variables a, b and c respectively. Then, these variables are passed to the function cyclicSwap(). Instead of …
Hits: 4 (C++ programming Example for Beginners) C++ Program to Find Transpose of a Matrix This program takes a matrix of order r*c from the user and computes the transpose of the matrix. In this program, user is asked to entered the number of rows and columns. The value of rows and columns should be less than 10 …
Hits: 7 (C++ programming Example for Beginners) C++ Program to Add Two Matrix Using Multi-dimensional Arrays This program takes two matrices of order r*c and stores it in two-dimensional array. Then, the program adds these two matrices and displays it on the screen. In this program, user is asked to entered the number of rows r and …
Hits: 0 (C++ programming Example for Beginners) C++ Program to Calculate Standard Deviation This program calculates the standard deviation of 10 data using arrays. This program calculates the standard deviation of a individual series using arrays. Visit this page to learn about Standard Deviation. To calculate the standard deviation, calculateSD() function is created. The array containing 10 elements …
Hits: 2 (C++ programming Example for Beginners) C++ Program to Find Largest Element of an Array This program takes n number of element from user (where, n is specified by user) and stores data in an array. Then, this program displays the largest element of that array using loops. This program takes n number of element from …
Hits: 7 (C++ programming Example for Beginners) C++ Program to Calculate Average of Numbers Using Arrays This program takes n number of element from user (where, n is specified by user), stores data in an array and calculates the average of those numbers. Example: Calculate Average of Numbers Using Arrays #include <iostream> using namespace std; …
Hits: 2 (C++ programming Example for Beginners) C++ Program to Calculate Power Using Recursion This program calculates the power of a number using recursion where base and exponent is entered by the user. Example: Program to Computer Power Using Recursion #include <iostream> using namespace std; int calculatePower(int, int); int main(){ int base, powerRaised, result; cout …
Hits: 5 (C++ programming Example for Beginners) C++ program to Reverse a Sentence Using Recursion This program takes a sentence from user and reverses that sentence using recursion. This program does not use string to reverse the sentence or store the sentence. Example: Reverse a sentence using recursion. #include <iostream> using namespace std; void …