C++ program to print second largest element in array In this program, you need to print the second largest element of the given array. For that, first sort the array in descending order. When the array is sorted in descending order the second largest element will be at the 1st index position. Print the 1st index position element. Consider the example array…
Read moreC++ program to print second smallest element of the array In this program, you need to print the second smallest element of the given array. For that, first sort the array in ascending order. When the array is sorted in ascending order the second smallest element will be at the 1st index position. Print the 1st index position element. Consider this example…
Read moreC++ program to find and print the smallest element of the array The below program searches and prints the smallest element in the array. In this program, I have used a variable small and initialized it to the first element of the array. You can take any other variable but it should not be greater than the smallest element If you do not …
Read moreC++ program to count occurrences of an array element In this program, you will be counting how many times any particular element occurs in an array. Take all the inputs from the user, set the counter to zero. Traverse through the array and check the element matches with the given element or not. If the match is found increase the counter. Finally, print th…
Read moreC++ program to print multiplication of largest and smallest element of array Take inputs from the user. Sort the array in ascending order then the smallest element will be at index position 0 and the largest element will be at index position size-1 . Take a variable "mul" to store the multiplication of the largest and smallest element. Print the …
Read moreC++ program to check given year is leap year or not In a leap year, February has 29 days making it a total of 366 days in a year. Following conditions are tested to determine a year is a leap year or not. Divisible by 4 and 400 - Leap Year Divisible by 100 - Not a Leap Year for rest - Not a Leap Year To check the given year is a leap ye…
Read morePangram string program in C++ English has a total of 26 alphabets. If a string comprises all the English alphabets in it then it is called a pangram . A pangram is a popular program in interviews. This program can be executed in several ways but I will use a simple and easy-to-understand approach here. Code: #include <bits/stdc++.h> using namespace s…
Read moreProgram to Convert first character uppercase in a String Code #include <bits/stdc++.h> using namespace std; char lower(char c){ // to check & convert uppercase to lowercase if(c>=65 && c<=90){ return c+32; } else{ return c; } } char upper(char c){ //to check & conv…
Read more//Program to convert uppercase alphabet lowercase and lowercase alphabet to uppercase in a string #include <bits/stdc++.h> using namespace std; int main() { string s; //requesting string cin>>s; int l=s.length(); …
Read more//Program to print the no. of LOWERCASE, UPPERCASE, NUMBERS, SPACES & SYMBOLS in a String #include <bits/stdc++.h> using namespace std; int main() { string s; //requesting string cin>>s; int l=s.length(); …
Read more//Program to Count no of Occurrences of a Character in a String #include <bits/stdc++.h> using namespace std; int main() { cout<< "Enter a String: " ; //requesting a string string s; getline(cin,s); //to read space separated input cout<< "\nEnter a character: …
Read moreProgram to count no words in a given string Code #include <bits/stdc++.h> using namespace std; int main() { cout<< "Enter a String: " <<endl; //requesting a string string s; getline(cin,s); //to read space separated input int count=1;…
Read moreProgram to check given string is Palindrome or not in C++ Code #include <bits/stdc++.h> using namespace std; int main() { string s; cout<< "Enter a string" <<endl; //Requesting String cin>>s; string t=s; //Sto…
Read moreProgram to check strong numbers in a given range Code #include<bits/stdc++.h> using namespace std; int main(){ cout<<"Enter a Range"<<endl; //Requesting the range int m,n; cin>>m>>n; for(int i=m;i<=n;i++){ …
Read moreC++ Program to print factorials of a given range In this program you need to print all the factorials of numbers you encounter in a specific given range. The logic is same as of the normal factorial program that is multiplying all the numbers from till current number. Only one loop will be added to the same logic to traverse through the range. Code #include&…
Read moreProgram to check given number is palindrome or not What is Palindrome Number? (Read Here) Code #include <iostream> using namespace std; int main() { cout<<"Enter a number "<<endl; //Requesting a Number int n; cin>>n; int temp=n; //to store original number for …
Read moreC++ Program to reverse and print the given number Take any integer as input from the user. Take a variable to store the reversed number. In this program, I have used the while loop , modulo, and division operator to reverse the number. To know more about these operators you can visit operators in C++ and for the loop visit Loops in C++. …
Read more
tcs
Copyright © 2021 Coding Demons All Rights Reseved
Social Plugin