**Unformatted text preview: **ebnath
Questions:
[Total Marks: 10x10 = 100 points]
1. A positive integer is called a perfect number if it is equal to the sum of all of its divisors.
excluding itself. For example, 6 and 28 are the two examples of perfect number, as
6 = 3+ 2 + 1 and 28 = 14 + 7+4 + 2 + 1
Now write a C program that will take a number as user input and check whether the number
is perfect or not.
Sample Input
Sample Output
Enter n: 6
6 is a perfect number!
Enter n: 28
28 is a perfect number!
Enter n: 32
32 is not a perfect number!
2. Write down a C program that will compute x" where x and n are integers. Both x and n
will be input to your program and they can be either positive or negative.
Sample Input
Sample Output
Enter x: 5
Result: 125.000
Enter n: 3
Enter x: 5
Result: 0.008
Enter n: -3
Enter x: -5
Enter n: 3
Result: -125.000
Enter x: -5
Enter n: -3
Result: -0.008
3. Write a C program which will take n as user input and display the number pyramid of base
size (2n-1) as shown in the sample output.
Sample Input
Sample Output
Enter n: 5
1
12 3
12345
1234567
1 2 3 4 5 6 7 8 9
4. Write a C program which will take n as user input and display the alphabet pyramid of
base size (2n-1) as shown in the sample output.
Sample Input
Sample Output
Enter n: 5
A
A B C
ABCDE
ABCDEFG
ABCDEFGHI
5. A palindromic number is a number that is the same when written forwards or backwards,
i.e. 12321, 94049, 543345 etc.
Now, write down a C program that will take a number as user input and check whether the
number is palindrome or not, using a user-defined function int isPalindrome(int n).
Function isPalinrome will return 1 if the number is a palindrome, otherwise return 0....

View
Full Document

- Fall '11