Introduction
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
C++ Memory Management: new and delete
Function Pointer in C++
C++ Switch statement (With Examples)
C++ Break Statement (With Examples)
C++ Pointer and Array (with Examples)
Type Conversion in C++
C++ Variables and Literals
C++ Data Types
Functions in C++
C++ Function Types
c++ Basic Input And Output With Examples
Function Overloading in C++
C++ Switch Case
Storage Classes in C++
continue statement in c++
C++ Break Statement
Return By Reference in C++
C++ Pointers and Functions
All Number Patterns in C++ programming Language
C++ Program to Generate Multiplication Table
All Matrix programs with examples
All pointer programming exercises in C++
List of Array in C++ Programs with Examples
List of Switch case programs with an examples
List of C++ Language Loop Programs with Examples
Alphabet Pattern Programs in C++ Language
250 C++ Program Examples & Solutions
All Star Pattern Programs In C++ Language
List of c++ language basic programs
Write C++ Program to interchange diagonals of a matrix
Write C++ Program to Find the Frequency of Odd & Even Numbers in the given Matrix
Write C++ Program to Find sum of each row and columns of a matrix
How To Find Transpose Of A Matrix In C++ Program
C++ Program To Check Two Metrices Are Equal Or Not
C++ Program To Multiply Two Matrices
How To Add Two Matrices In C++ Program
Write C++ program to right rotate an array
Write C++ program to find reverse of an array
Write C++ program to put even and odd elements of array in two separate array
Write C++ program to merge two sorted array
Write C++ program to count total duplicate elements in an array
Write C++ program to delete all duplicate elements from an array
Write C++ program to count number of each element in an array
Write C++ program to copy all elements of one array to another
C++ Program To Sort Array In Ascending Order
C++ Program to Print all Unique Element in an Array
Write C++ program to insert an element in array
C++ Program To Find Maximum And Minimum Element In Array
C++ program to count even & odd elements
Write Sum of Elements in an array in C++ Programming
C++ Program To Read And Print Elements Of Array
How To Count Total Number Of Negative Elements In Array In C++
C++ Program To Print All Negative Elements In An Array
C++: Print Elements Of Array In Revers Order Using Pointer
How To Concatenate Two Strings In C++ Using Pointers
Write C++ program to copy one string to another string
Write C++ program to find length of string using pointer
C++ Program to Find Sum of Array Elements
Write C++ program to add two numbers using pointers
Write C++ program to swap two numbers using pointers
Write C++ program to find maximum and minimum elements in array using recursion
Write C++ program to check palindrome number using recursion
Write C++ program to find factorial of a number using recursion
Write C++ program to generate nth fibonacci term using recursion
Write C++ program to find sum of array elements using recursion
Write C++ program to print elements of array using recursion
Write C++ program to find HCF of two numbers using recursion
Write C++ program to find LCM of two numbers using recursion
Write C++ program to find reverse of a number using recursion
Write C++ program to print even or odd numbers in given range using recursion
Write C++ program to find sum of natural numbers in given range using recursion
Write C++ program to find power of a number using recursion
Write C++ program to print perfect numbers between given interval using function
Write C++ program to find diameter, circumference and area of circle using function
Write C++ program to find prime numbers in given range using functions
Write C++ program to print all strong numbers between 2 numbers
How To Find length of Length of String c++
Write C++ program to convert decimal number to binary using function
Write C++ program to convert binary number to decimal
Write C++ program to find cube of a number using function
Write C++ program to check prime and armstrong number by making functions
Write C++ program to check even or odd using functions
Write C++ program to find maximum number using switch case
C++ Program to Print Gender Male or Female
Write C++ program to check vowel or consonant using switch case
How To C++ Odd or Even Program by Using Switch Case Statement
Simple Calculator Program in C++ using Switch Case
c++ program to print day of week name using switch case
Write C++ Program To Print Number Of Days In a Month Using Switch Case
Write C++ program to find LCM of two numbers
Write C++ program to find HCF of two numbers
Write C++ program to print number in words
Write C++ program to check whether a number is palindrome or not
C++: To Check A Number Is Prime Or Not Using While,For Loop
Write C++ program to calculate compound Interest
Write C++ program to find Armstrong numbers between 1 to n
Write C++ program to check whether a number is Armstrong number or not
Write C++ program to find factorial of any number
C++ Power Function | C++ pow()
C++ Program To Reverse A Number Using While And For Loop
Write C++ program to calculate product of digits of a number
Write C++ program to find first and last digit of any number
Write C++ program to find the sum of first and last digit of any number
Write Program To swap First and Last Digit of a Number C++
Write C++ program to find sum of odd numbers between 1 to n
Write C++ program to find sum of even numbers between 1 to n
How To Print Sum Of Digits Enter By User In C++ Program
How To C++ Program To Reverse a Number
Write C++ program to print multiplication table of a given number
Write Program to Print ASCII Value In C++ For all Uppercase Alphabet
Write C++ program to print alphabets from a to z
C++ program to check Triangle can be formed from angles.
C++ program to count total number of notes in entered amount.
C++ Program to Enter Month and Print Days.
C++ To Calculate Total Marks Percentage Division Of Student
C++ program to find the eligibility for an engineering course based on the criteria
C++ program to find the eligibility of admission for an engineering course based on the following criteria
c++program to accept two integers and check they are equal or not
C++ program to print day name of week
C++ Program to Check Alphabet Digit or Special character
C++ program to check entered character vowel or consonant
C++: Check Uppercase Or Lowercase Alphabets
C++ program to check number is positive, negative or zero
C++ program to check alphabets using conditional operator
C++ Program To Check Leap Year Using Conditional Operator
C++: Find Largest Among Three Variables Using Nested If
C++ Program to Find Largest Number
C++ program to find the largest number among three numbers
C++: Check An Integer Entered By The User Is Odd Or Even
Write C++ program to compare two strings using strcmp
C++: Count Alphabets Digits Special Character In String
Write C++ program to reverse a string enter by user
Write C++ program to change string to lower case without strlwr
C++ Program to Change String to Upper Case
Write C++ program to convert a string to upper case
C++ Program To Convert A String To Lower Case
C++ Program to Find String Length
Write C++ program to concatenate two strings
C++ Program to convert days to years, weeks and days
C++ Program to Calculate Area of Rectangle
C++ Program to Calculate Area of Square
How To Convert Area Of Circle In C++ Program
C++ Program To Print Ascii Value
C++ Program To Find Size Of Data Types
C++ Program to Convert Farenheit to Celcius
C++ Program to Convert Celsius to Fahrenheit
How To Print Convert Feet To Meter In C++ Program
C++ Program to perform all arithmetic operations
C++ Program to Multiply two Floating Point Numbers
C++ Program to Swap Values of Two Variables
C++ Program to Add Two Integers
C++ Program to Print “Hello, World!”
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
#include <iostream>
#define size 5 // defining Size of the array
using namespace std;
void printArray(int arr[]);
void rotateByOne(int arr[]);
int main()
{
int i, num;
int arr[size];
cout<<"Enter 5 elements array: ";
for(i=0; i<size; i++)
{
cin>>arr[i];
}
cout<<"Enter number of times to left rotate: ";
cin>>num;
// Actual rotation
num = num % size;
// Printing array before rotation
cout<<"Array before rotationn:\n "<<endl;
printArray(arr);
// Rotating array n times
for(i=1; i<=num; i++)
{
rotateByOne(arr);
}
// Printing array after rotation
cout<<"\nArray after rotation: "<<endl;
printArray(arr);
return 0;
}
void rotateByOne(int arr[])
{
int i, first;
// Storing first element of array
first = arr[0];
for(i=0; i<size-1; i++)
{
// Moving each array element to its left
arr[i] = arr[i + 1];
}
// Copying the first element of array to last
arr[size-1] = first;
}
//Printing the given array
void printArray(int arr[])
{
int i;
for(i=0; i<size; i++)
{
cout<<arr[i]<<"\t";
}
}
Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …
C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …