# C program need help

Page 1 of 1

## 1 Replies - 687 Views - Last Post: 09 April 2010 - 03:58 AMRate Topic:     //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=167073&amp;s=39d35276cde7e39e6119bd962e13554d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 JunaidSaeed Reputation: -4
• Posts: 6
• Joined: 09-April 10

# C program need help

Posted 09 April 2010 - 03:57 AM

Question #1: Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data.
As an example, January 1, 2010 is day 1. December 31, 2009 is day 365. December 31, 2010 is 366 (since 2010 is a leap year). A year is a leap year if it is divisible by four, except that any year divisible by 100 is leap year only if it is divisible by 400.
Your program should accept the month, day and year as integer. Include:
- function validate_date() which validates date entered.
- function is_leapyear() to find if the year is a leap year or not.
- function calculate_day () to calculate the day from the date

Question #2: A Pythagorean triplet is a set of three natural numbers, a b c, for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52
Likewise, there exists exactly one Pythagorean triplet for which a + b + c = 1000. Write a program that finds the product abc for an input value n.

Question #3: Write a program that finds the sum of primes which are below:
Thousand
Ten Thousand
Hundred Thousand
For instance, the sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. In order to calculate this sum, you need to first find the primes below the above specified value.

Question #4:

a) Write a program that find the sum of the digits in the number 100! Where n! means n (n 1) ... 3 2 1

For instance, sum of digits of 5! Then first calculate factorial as:
5! = 5 x 4 x 3 x 2 x 1 = 120
Now calculate sum of digits as:
120 => 1 + 2 + 0 => 3 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Write a program that find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included

Question #5: You are given the following information, but you may prefer to do some research for yourself.
1 Jan 1900 was a Monday
Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.
A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
Write a program that determines how many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?

PLease hellp as soon as possible

Is This A Good Question/Topic? 0

## Replies To: C program need help

### #2 sarmanu Reputation: 967
• Posts: 2,362
• Joined: 04-December 09

## Re: C program need help

Posted 09 April 2010 - 03:58 AM