C/C++ Programs

Simlple Calculator Using OOP

 

Read More

Maximum or largest number in array c++ code

Write a C++ program which find largest or maximum number in array using for loop and if statementConcept used Array in c++ for loop if statement Post contains c++ code and Dry run of code How program works Program first take size of array from user Then input element or array one by one then…

Read More

Random number generator in c++ programming

This tutorial contains How to generate a random number using rand() Simple example using rand() function Generate random number in a specific range dice example To generate a random number in c++ program first we have to include a header file which is #include<cstdlib> because we have to use a function from that library which…

Read More

How to use rand, srand and time function cpp

This tutorial contains rand(); srand() and time() concept and how to use these functions srand() example with rand() with in a for loop rand() srand() and time program code with for loop Random numbers are not truly random why? Computers actually cannot generate truly random numbers because they are not human. Computer follows some algorithms…

Read More

Find maximum and minimum number in array c++ code

This Tutorial contains: C++ code to find maximum and minimum number in array  Program basic working what is used in program and how  Dry run of the program with respect to variable values for better under standing Concept used: Arrays in c++  for loop if statement Random numbers Write a program to find maximum and…

Read More

Bubble sort in c++ code example

Tutorial contains Bubble sort c++ code Code dry run with explanation Image view of code Concept used for bubble sort in this examples are:     int array     nested for loop     if statement C++ code #include<iostream> using namespace std; int main(){ //declaring array int array[5]; cout<<"Enter 5 numbers randomly : "<<endl; for(int i=0; i<5; i++) { //Taking input in array cin>>array[i]; } cout<<endl; cout<<"Input array is: "<<endl; for(int j=0; j<5; j++) { //Displaying Array cout<<"tttValue at "<<j<<" Index: "<<array[j]<<endl; } cout<<endl;…

Read More

Recursive function in c++ programming

This c++ tutorial contains What is a recursion? What are its important parts A simple example code How it affects stack Recursion in c++ programming It is one of the most annoying or difficult concept for c++ programming for beginners. Yes it is difficult for a beginner to understand because sometimes its execution goes in…

Read More

Cpp Tutorial Functions in c++ examples

This cpp tutorial contains Introduction to functions in c++ Different methods to write functions Examples of c++ functions code Types of functions in c++ What are Functions and why they are important in c++ programming Language A C++ function may have 2 or 3 phases Prototype Calling Definition or body of a function  First one…

Read More

C++ program to find factorial using recursion

Write a program to find the Factorial using recursive function. User will enter a number and program should display result.Concept  used: Recursive function (returns number) int function(int n); if-else statement Static variable How program works User enters a number which stores in variable 'num' Then number passes as argument in function call  A static variable…

Read More

Simple Binary search code example in cpp

Write a cpp program which takes some elements in an array and a Key in variable then program use Binary Search c++ Algorithm to find the key. Concept used: Functions, loop, and if-else statements in c++Program Explanation: Program has two functions One to sort array using bubble sort Second to apply Binary Search on array…

Read More

c++ program to add two matrices

Write a c++ program to add two matrix using 2-D arrays use any c++ compiler, turbo c++, visual studio or codeblocks. 2D arrays are just like tables which consist of rows and colums and each cell contains a value. Matrix addition as   1     2         1     2        …

Read More

Matrices Multiplication in C++ Code Tutorial

Write a simple c++ program to multiply two matrices using 2D arrays. Use any compiler turbo c, visual studio or codeblocks compiler. Program Explanation: Here is the simple example for beginners to understand the basic working of 2Dimensional arrays. Program is very simple it takes input in two 2D arrays each with size of 2X2.…

Read More

Passing array to a function cpp code

 This Cpp Tutorial contains 3 ways to pass an array to a function Each way and its usage 3 c++ codes examples How codes are working Sample output Compiler used "C++ CodeBlocks Compiler" Write a program which declares an array, initialize it then pass to a function. Function takes square of array values and update…

Read More

Cpp Function to Find Largest and smallest number in array

This Cpp tutorial contains Cpp array with random integer values Passing array to function if statement with in for loop Calculate result in function and display  Compiler used: CodeBlocks Cpp Compiler Write a program which generates some random number and store in array after it program pass array to a function which calculates maximum and…

Read More

Insert update delete an element in array cpp code

Write a c++ program which manages data in array having insert, update and delete value functions. Program should be menu based properly asking for user to enter an option and on wrong or invalid input program should display proper message and ask user to enter value again. You can use any C++ compiler.Cpp code should…

Read More