1. Write a program to print out all Armstrong numbers between 1 and 500.
If the sum
of cubes of each digit of the number is equal to the number itself, then the number
is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3
*3*3).
Output
Armstrong numbers between 1 and 500 are:
1
153
370
371
407
2. Write a C program to take user input for the number of rows in the hollow full pyramid.
The program should prompt the user to enter a positive integer and then print the
corresponding pyramid using asterisks (*).
Output
3. Write a C program that implements the Collatz conjecture. The program should
take an integer input from the user and print the sequence until it reaches 1,
following the rules:
● If the number is even, divide it by 2.
● If the number is odd, multiply it by 3 and add 1.
Output
1. Enter a positive integer: 18
Collatz sequence: 18 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4
21
2. Enter a positive integer: 49
Collatz sequence: 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13
40 20 10 5 16 8 4 2 1
4. Write a C program to create a simple number guessing game where the program
randomly selects a number between 1 and 100, and the user has to guess it. The
program should provide hints if the guess is too high or too low, and keep track of
the number of attempts.
Output
Welcome to the Number Guessing Game!
I have selected a number between 1 and 100. Can you guess it?
Enter your guess: 9
Too low! Try again.
Enter your guess: 75
Too low! Try again.
Enter your guess: 80
Too high! Try again.
Enter your guess: 77
Too low! Try again.
Enter your guess: 79
Too high! Try again.
Enter your guess: 78
Congratulations! You've guessed the number 78 in 6 attempts.
5. Write a C program to generate all unique combinations of three user-provided
integers without repetition. The program should prompt the user to input three
distinct integers and use nested loops to create and display all possible
combinations of these integers. Each combination should be unique, with no
integer repeated within a combination.
Output
Enter the first integer: 5
Enter the second integer: 9
Enter the third integer: 7
All unique combinations without repetition are:
597
579
957
975
759
795