1-Write a program that determines the day number (1 to 366) in a year for a date that

provided as input data. As an example, January 1, 1994, is day 1. December 31, 1994, is
day 365. December 31, 1996, is day 366, since 1996 is a leap year. A year is a leap year
if it is divisible by four, except that any year divisible by 100 is a leap year only if it is
divisible by 400. Your program should accept the month, day, and year as integers.
2-The table shows the normal boiling points of several substances. Write a program that
prompts the user for the observed boiling point of a substance in ºC and identifies the
substance if the observed boiling point is within 5% of the expected boiling point. If the
data input is more than 5% higher or lower than any of the boiling points in the table, the
program should output message “Substance unknown”.
Substance Normal boiling point (ºC)
Water 100
Mercury 357
Copper 1187
Silver 2193
Gold 2660

#include <stdio.h>

int isleap(int year);

void displaydate(int month ,int date ,int year,int daynumber);

int main (void) {

int month;
int day;
int year;
int leapyear;
int daynumber;

printf(" enter a month");
scanf("%d",&month);

printf(" enter a day");
scanf("%d",&day);

printf(" enter a year");
scanf("%d",&year);

leapyear= isleap( year);

displaydate( month,day,year,daynumber);

daynumber = leapyear && month > 2 ? day+1 : day;

switch(month) {

case 1 : daynumber = day;
break;

case 2 : daynumber = 31 + day;
break;

case 3 : daynumber = 59 + day + 1;
break;

case 4 : daynumber = 89 + day;
break;

case 5 : daynumber = 120 + day;
break;

case 6 : daynumber = 150 + day;
break;

case 7 : daynumber = 181 + day;
break;

case 8 : daynumber = 212 + day;
break;

case 9 : daynumber = 232 + day;
break;

case 10 : daynumber = 263 + day;
break;

case 11 : daynumber = 293 + day;
break;

case 12 : daynumber = 324 + day;
break;

default:
break;
}

return 0;
}

int isleap(int year)
{
if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0)) {
printf("%d 1", year);
return 1;
}
else {
printf("%d 0", year);
return 0;
}
}

void displaydate(int month ,int date ,int year,int daynumber)
{
printf("\n your date is %d and the day number is %d",month,date,year,daynumber);

}

Sure! Here are the step-by-step programs for the two tasks:

1. Determine the day number in a year for a given date:

Step 1: Get the input for the month, day, and year as integers.
Step 2: Check if the year is divisible by 4, except for years divisible by 100 but not by 400. If true, it is a leap year.
Step 3: Create a list of the number of days in each month. Consider 28 days in February for non-leap years and 29 days for leap years.
Step 4: Calculate the day number:
- Start with 0 as the initial day count.
- Loop through the months preceding the given month and add the number of days in each month to the day count.
- Add the day of the given month to the day count.
Step 5: Output the day number.

Here's the program in Python:

```python
def is_leap_year(year):
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
return True
return False

def get_day_number(month, day, year):
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

if is_leap_year(year):
days_in_month[1] = 29

day_number = 0
for i in range(month - 1):
day_number += days_in_month[i]

day_number += day
return day_number

month = int(input("Enter the month as a number (1-12): "))
day = int(input("Enter the day: "))
year = int(input("Enter the year: "))

day_number = get_day_number(month, day, year)
print("The day number is:", day_number)
```

2. Identify the substance based on the observed boiling point:

Step 1: Get the observed boiling point from the user.
Step 2: Define a dictionary with the substances and their expected boiling points.
Step 3: Check if the observed boiling point is within 5% of any of the expected boiling points. If true, output the corresponding substance.
Step 4: If the observed boiling point is more than 5% higher or lower than any of the boiling points, output "Substance unknown".

Here's the program in Python:

```python
def identify_substance(observed_boiling_point):
substance_boiling_points = {
"Water": 100,
"Mercury": 357,
"Copper": 1187,
"Silver": 2193,
"Gold": 2660
}

for substance, expected_boiling_point in substance_boiling_points.items():
lower_bound = expected_boiling_point - (0.05 * expected_boiling_point)
upper_bound = expected_boiling_point + (0.05 * expected_boiling_point)

if lower_bound <= observed_boiling_point <= upper_bound:
return substance

return "Substance unknown"

observed_boiling_point = float(input("Enter the observed boiling point (ºC): "))

substance = identify_substance(observed_boiling_point)
print("The substance is:", substance)
```

You can simply run the programs, input the necessary values, and get the desired outputs.

1- To write a program that determines the day number in a year for a given date, you can follow these steps:

1. Accept the input of the month, day, and year as integers.
2. Calculate if the given year is a leap year by checking the conditions: divisible by 4, not divisible by 100 unless divisible by 400.
3. Create an array or list to store the number of days in each month. For a non-leap year, February has 28 days; for a leap year, it has 29.
4. Use a loop to iterate through the months preceding the given month and add up the number of days in each month.
5. Add the number of days of the given month to the total.
6. Print the final sum as the day number in the year.

Here is a Python example:

```python
def is_leap_year(year):
if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
return True
else:
return False

def day_number_in_year(month, day, year):
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if is_leap_year(year):
days_in_month[1] = 29

day_number = sum(days_in_month[:month-1]) + day
return day_number

# Example usage:
month = int(input("Enter the month as an integer (1-12): "))
day = int(input("Enter the day as an integer: "))
year = int(input("Enter the year as an integer: "))

day_number = day_number_in_year(month, day, year)
print("The day number is:", day_number)
```

2- To write a program that identifies the substance based on the observed boiling point, you can follow these steps:

1. Accept the input of the observed boiling point in ºC from the user.
2. Create dictionaries or arrays to store the substances and their respective normal boiling points.
3. Iterate through the substances and compare the observed boiling point with the expected boiling point. If the observed boiling point is within 5% of the expected boiling point, print the substance name.
4. If the observed boiling point is more than 5% higher or lower than any of the boiling points in the table, print "Substance unknown".

Here is a Python example:

```python
def identify_substance(observed_boiling_point):
substances = {
"Water": 100,
"Mercury": 357,
"Copper": 1187,
"Silver": 2193,
"Gold": 2660
}

for substance, boiling_point in substances.items():
tolerance = 0.05 * boiling_point
lower_bound = boiling_point - tolerance
upper_bound = boiling_point + tolerance

if lower_bound <= observed_boiling_point <= upper_bound:
return substance

return "Substance unknown"

# Example usage:
observed_boiling_point = float(input("Enter the observed boiling point in ºC: "))

substance = identify_substance(observed_boiling_point)
print("The substance is:", substance)
```

These examples should give you a good starting point for implementing the desired programs.