Print the Pattern * * ** ** *** *** **** **** ********** Code #include<bits/stdc++.h> using namespace std; // Function to print space void space(int x) { while(x>0) { x--; cout<<" "; } } // Function to print star void star(int y) { while(y--) …
Read morePrint the Given Pattern * * * * * * * * * * * * * * * * * * * * * * * * * Code #include<bits/stdc++.h> using namespace std; // Function to print space void space(int x) { while(x>0) { x--; cout<<" "; } } // Function to print star void star(int y) { while(y--) { …
Read morePrint the Pattern ***** * * * * * * ***** Code #include<bits/stdc++.h> using namespace std; // Function to print star void star(int y) { while(y--) { cout<<" * "; } } // Function to print spaces void space(int x) { while(x>=0) { x--; cout<<" &qu…
Read morePrint the pattern * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Code #include<bits/stdc++.h> using namespace std; // Function to print star void star(int y) { while(y--) { cout<<" * "; } } // main function int main() { int n; cin>>n; for(int i=0;i<n…
Read morePrint the below Pattern * * * * * * * * * * * * * * * Code #include<bits/stdc++.h> using namespace std; // Function to print space void space(int x) { while(x>0) { x--; cout<<" "; } } // Function to print star void star(int y) { while(y--) { …
Read morePrint the Given Pattern * * * * * * * * * * * * * * * Code #include<bits/stdc++.h> using namespace std; //to print the spaces void space(int x) { while(x>=0) { x--; cout<<" "; } } //to print the stars void star(int y) { while(y--) { cout<<"* &q…
Read morePrint the below Pattern ***** **** *** ** * Code #include<bits/stdc++.h> using namespace std; //to print the spaces void space(int x) { while(x--) { cout<<" "; } } //to print the stars void star(int y) { while(y--) { cout<<"*"; } } //main functi…
Read morePrint the given pattern * ** *** **** ***** Code #include<bits/stdc++.h> using namespace std; //to print the spaces void space(int x) { while(x--) { cout<<" "; } } //to print the stars void star(int y) { while(y--) { cout<<"*"; } } //main functi…
Read moreC++ Program to print array in reverse order The array is one of the most asked topics in any coding exam. Hence one must know how to read and access array elements. The below is a basic program that explains how to read array elements and how to access and print them in reverse order. Code #include <iostream> using namespace std; int main() { int …
Read moreC++ program to search a given element in an array The below program simply takes all the inputs from the user and prints "PRESENT" if the element is found in the array and prints "ABSENT" if the element is not found in the array. This code is a simple execution of " The Linear Search Algorithm " in C++. Code #include…
Read moreC++ program to search and print index position of an element in array The below program is based on arrays. The user will provide array size and its elements along with the element whose index position the user wants to know. You need to search the element in the array if the element is found print " found at: index position ". If the e…
Read moreC++ 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 moreCopyright © 2021 Coding Demons All Rights Reseved
Social Plugin