# Category Archives: Program

## Write a Program to calculate area of a circle, a rectangle or a triangle depending upon user’s choice

Problem Statement  We need to write a program in C, C++, and Python, that is capable of returning the area of a circle, rectangle, and triangle based on the user choice and input. First, the user has the choice to select the geometry for which he/she wants to calculate the area. Then based on the geometry shape selected… Read More »

## Write a Program to print the truth table for XY+Z

Problem Statement We need to write a program that can print a truth table for the logic XY+Z. The XY+Z logic shows a AND operator between X and Y, and an OR operator between XY and Z. Algorithm The algorithm for this logic is pretty simple. We just need to create a nested three-level loop where the outermost… Read More »

Problem Statement We need to write a program in C, C++, and Python, that creates a loading bar on the console window. All these three programming languages support third-party packages or libraries to print a loading progress bar, but we will use the basic coding to implement one of our own. Algorithm The idea behind creating a process… Read More »

## Write a Program to Print the Following Pattern

Problem Statement We need to write a script in C, C++, and Python that can print the following pattern of Alphabets based on the user’s entered letter. Input  letter = F Output A AB ABC ABCD ABCDE ABCDEF Algorithm Ask the user to enter the height of the pattern h which ranges between 1 to 26 (A to… Read More »

## Write a Program to Print the Following Triangle

Problem Statement 1 We need to write a program in C, C++, and Python that can print the following triangle pattern, based on the user entered height. Let say the height of the triangle is 8 Input: height =8 Output * ** *** **** ***** ****** ******* ******** Algorithm The algorithm of this problem is pretty straightforward. Ask… Read More »

## Write a Program to print three numbers in descending order

Let’s say we have three numbers and we need to sort them in descending order, how would we do that? The answer is using the if-else statement. Every high-level programming language supports if..else statements. And in this programming tutorial, we will learn how to print three numbers in descending order. First, we will ask the user to enter… Read More »

## Write a Program to calculate sum and average of three numbers

In this tutorial, we will learn how to write a script in C, C++, and Python to calculate the sum and average of three numbers. The sum of three numbers can be calculated by using the addition operator between the numbers and to find out their average we can divide the sum by 3. Example 1 Input: 4… Read More »

## Write a Program to print given series:1 2 4 8 16 32 64 128

In this programming tutorial, we will learn how to print the following sequence using C, C++, Java, and Python programming languages. The Sequence: 1 2 4 8 16 32 64 128 265 ……… As you can see that the sequence starts for 1, and every next number is twice its first number. Now we will write a script… Read More »

## Write a Program to find quotient and remainder of two numbers

In this programming tutorial, we will write a program to find the quotient and remainder of two numbers. When we divide two numbers the result we get is the quotient, it is the number of times a division is divided completely. A remainder is a value that is left after division when the divisor could not divide the… Read More »

## Write a Program to Find Cube of a Number using Functions

Function in programming languages used to perform specific tasks. The functions increase the reusability of code and make the overall code more modular and readable. In this programming tutorial, we will learn how to find a cube of a number using functions. C Program #include //function that will find the cube of a number int cube(int num) {… Read More »