0% found this document useful (0 votes)
4 views3 pages

Nice Numbers and Proper Divisors in C

The document outlines a series of programming tasks in C, focusing on various mathematical operations and conditions, including calculating areas, volumes, and properties of numbers. It also includes tasks involving loops for factorials, Fibonacci numbers, prime checks, and digit manipulations. Additionally, it covers nested loops for generating patterns based on user input.

Uploaded by

lipto4444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Nice Numbers and Proper Divisors in C

The document outlines a series of programming tasks in C, focusing on various mathematical operations and conditions, including calculating areas, volumes, and properties of numbers. It also includes tasks involving loops for factorials, Fibonacci numbers, prime checks, and digit manipulations. Additionally, it covers nested loops for generating patterns based on user input.

Uploaded by

lipto4444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

I/O + Operation:

1. Take two numbers as input: length and width of a rectangle and print the area of that.
2. Take two numbers as input: radius and height of a cone and print the volume of that.

Condition:
3. Take three numbers as input: the three angles of a triangle and whether the triangle
is valid or not (angle value should be such that 0 < value < 180).
[Recall that a triangle is valid if the sum of all the three angles is equal to 180
degrees.]
4. Take 4 numbers as input and print the second maximum of them.
5. Write a C program that takes as input two positive integers n and d and outputs
whether d is a proper divisor of n.
[Recall that a proper divisor of a positive integer n is a divisor of n that is not equal to
n. So, 1, 2, and 3 are proper divisors of 6 but 6 isn’t.]
6. Take an integer as input for a year and check whether it is a leap year or not.

Looping:
7. Take an integer N as input and find its factorial (N!).
8. Write a C program to print the nth Fibonacci number.
9. Take an integer N as input and check whether N is a prime number or not.
[A natural number (1, 2, 3, 4, 5, 6 etc.) is called a prime number if it is greater than 1
and has only two factors: 1 and the number itself.]
10. Write a C program that takes as input a positive integer n and outputs the number of
proper divisors of n.
11. A positive integer n is called Nice if it has at least three proper divisors and is equal
to the sum of its three largest proper divisors. For example, 6 is Nice because its
three largest divisors (in descending order) are 3, 2, and 1 and 6=3+2+1. Write a C
program that takes as input a positive integer n and outputs whether or not it is Nice.
12. Take an integer N as input and check whether N is a power of 2.
13. Take two numbers as input: x and y. Now, print n for which the following relationship
holds:
𝑛
𝑥 = 𝑦
Otherwise, print “could not find n”. Assume that n is a natural number and
2 < 𝑛 < 15.
14. Take two integers n and r as input and print the value of nCr.
15. Take an integer N as input and print the number of digits in N.
[e.g. N=2359 should output 4, N=900 should output 3 etc.]
16. Take a number N as input and print how many even and odd digits it has.
17. Take an integer N as input, reverse it and then print that.
[e.g. N=2359 should output 9532, N=900 should output 9 etc.]
18. Take a number N as input and print whether it is a palindrome or not.
[A palindromic number is a number that remains the same when its digits are
reversed. For example, 984489 and 12321 are palindromes, however, 1234 and
985489 are not.]
19. Take an integer N as input, swap the last and second last digit of it and then print
that.
20. Take an integer N having an even number of digits as input, split the first and second
half as separate numbers and print them. [For example, split 984489 into 984 and
489]
21. Take an integer N having an even number of digits as input, set zero to the odd
positions of that integer and output that. [For example, 984489 should produce
904080 and 1234 should produce 1030]
Nested Looping:
22. Take an integer N as input and print all prime numbers from 2 to N inclusive.
23. Print the following pattern for input n.

n=3 ***
**
*

n=5 *****
****
***
**
*

24. Print the following pattern for input n.

n=3 *
***
*****

n=5 *
***
*****
*******
*********

You might also like