## C/C++ Program to Find the Largest Divisor of a Number

Write a program to find the largest divisor of a number in C/C++. The program should print the greatest proper divisor of input number – N. A number X is a proper divisor of a number Y if X divides Y and X is less than Y. For example, Input 2145 Output 715 Explaination Proper …

## C Program to Find Smallest Divisor of an Integer

Write a program to find smallest divisor of an integer in C. For example, Input 2135 Output 5 Input 49 Output 7 Explaination Divisors of 305 = { 5, 7, 35, 61, 305, 427, 2135 } Smallest Divisor = 5 Divisors of 49 = { 7, 7, 49 } Smallest Divisor = 7 Note: ‘1’ …

## Lua Program to Find Factorial of a Number

Write a program to find factorial of a number in Lua. For example, Input 5 Output 120 Lua Program to Find Factorial of a Number Using Loop Lua Program to Find Factorial of a Number Using Recursion Note Using a loop is much more efficient than using recursion. Recursion uses an internal stack to store …

## QBasic Program to Check if a Number is Palindrome or not

Write a program to check if a number is palindrome or not in QBasic. For example, Input 12321 Output Palindrone Input 43823 Output Not Palindrome What is Palindrome number? A number is palindrome if it is equal to it’s reverse. For example, reverse of 121 is also 121, this implies 121 is palindrome whereas reverse …

## Program to Print Truth Table of Given Boolean Expression

Write a program to print truth table of any given Boolean Expression. For example, Input A.B’+C Output A         B         C         f 0         0         0         0 0         0         1         1 0         1         0         0 0         1         1         1 1         0         0         1 1         0         1         1 1         1         0         0 1         1         1         1 Steps Ask …

## C/C++ Program to Print First n Perfect Numbers

Write a program in C/C++ to print first n perfect numbers. For example, Input 3 Output 6 28 496 What is a perfect numbers? A Perfect number is a positive number such that the sum of the proper divisors of the number is equal to the number itself. For example, the proper divisors of 6 …

## QBasic Program to Count the Number of Words in a Sentence

Write a QBasic program to count the number of words in a sentence. For example, Input My Name is John Smith Output 5 Method 1 The number of words in a typical sentence is one more than the number of spaces ( ” ” ) in a sentence. In this method, we use a loop …

## QBasic Program to Print Multiplication Table of a Given Number

Write a program to print multiplication table of a given number in QBasic. For example, Input 5 Output 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * …

## QBasic Program to Check if Number is Even or Odd

Write a program in QBasic to check if the input number is even or odd. Program using IF..ELSE Program using only IF Program using Select Case Program using subroutine Program using subroutine – Passing input as an argument Program using Function Program using Function – Passing input as an argument Program using Function – Passing …

## QBasic Program to Find Factorial of a Number

Write a program to find factorial of a number in Qbasic. For example, Input 4 Output 24 Explanation 4! = 4 * 3 * 2 * 1 = 24 Steps First, the program asks the user to enter a number – n. Then we initialize a variable fact = 1. After that, we use a …