c++

c++ Concepts

Factorial Program in C

Write a Program to Find the Factorial of a number in C. Example, Input: 5Output: 120 Factorial can be calculated in 2 ways Factorial using Loop (Iteratively) Factorial using recursion (recursively) Factorial Program in C Using Loop (Iterative method) We can use for-loop, while-loop or do-while loop. Factorial Program in C using for-loop Factorial Program …

Factorial Program in C Read More »

Write a C Program to find maximum between 3 numbers.

Write a C Program to find maximum between 3 numbers. We will learn how we can find the maximum of 3 numbers in c/c++. The code will work in all languages with few modifications. Prerequisite Knowledge Relational Operator Ternary/Conditional Operator if..else Statement Basic C/C++ Programming knowledge The problem can be solved in various way. We …

Write a C Program to find maximum between 3 numbers. Read More »

How to sort an array in descending order using sort() in c++?

The C++ STL function sort() by default sorts the array in ascending order. If we want to sort array in descending order using sort(), we need to use a Comparator Function. Syntax Sort Array in Descending Order Using sort() We can use the inbuilt greater<type>() function to arrange array in descending order. greater<type>() compares the …

How to sort an array in descending order using sort() in c++? Read More »