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 »

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 »

How To Make a Game With Python

Python is one of the simplest and straightforward programming languages, that make it easy for the developer to put logic simply, without worrying about the complex syntax of the programing language. And what could be more logical than writing the code for a game in a programming language? When it comes to development with Python, rather than building… Read More »

Move all zeros present in an array to the end

We have given an integer array, and we need to move all the zeros present in it to the end. And the output array must maintain the relative order of its elements, which means the order of other elements (except 0) must be in the same order. Example Input : [5,0,7,4,5,3,0,1,0,6] Output: [5,7,4,5,3,1,6,0,0,0] Explanation  In the output, you can… Read More »

Sort an array in one swap whose two elements are swapped

Problem Statement We have given an array in which all elements are sorted except two. Those two unsorted elements are swapped and we need to swap back so the array can be completely sorted. The challenge is we need to swap back the elements in linear time without duplicating the array or using any extra space. For Example… Read More »