1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Inessa [10]
3 years ago
5

Write a function named days() that determines the number of days since January 1, 1900 for any data passed as a structure. Use t

he Date structurestruct Date{int month;int day;int year;};In writing the days() function, use the convention that all years have 360 days and each month consists of 30 days. The function should return the number of days for any Date structure passed to it. Write a main () function to test your function.
Computers and Technology
1 answer:
Lisa [10]3 years ago
3 0

Explanation:

#include <stdio.h>

#include <stdlib.h>

struct date

{

int month;

int day;

int year;

};

int days(struct date *d)

{

int daysTotal;

// Adding days from date::day

if (d->day > 0 && d->day < 31) // Only execute if day is valid

{

daysTotal = d->day - 1;

}// Adding days from date::month

if (d->month > 0 && d->month < 13) // Only execute if month is valid

{

daysTotal += 30 * (d->month-1);

}// Adding days from date::year

if (d->year > 1899) // Only execute if year is valid

{

daysTotal += 360 * (d->year-1900); // subtracting 1900 years

}

return daysTotal; // This may still be a negative value, but is accepted here for simplicity

}

int main()

{

struct date myDate;

printf("Enter a Month: ");

scanf("%d", &myDate.month);

printf("Enter a Day: ");

scanf("%d", &myDate.day);

printf("Enter a Year: ");

scanf("%d", &myDate.year);

printf("the date you entered = %d days", days(&myDate));

return 0;

}

You might be interested in
True or false while the internet and social media are vital for spreading campaign messages, television advertisements are consi
liq [111]
Salutations!

The answer is false. Social media, internet, television, are all effective to spread campaigns, news etc. This is the easiest and the fastest way to get information. All these sources are very strong and can reach information any where in the world within minutes.

Hope I helped (:

have a great day!
7 0
4 years ago
Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the
ddd [48]

Answer:

See explaination for program code.

Explanation:

inputFileName = input("Input filename: ") outputFileName = input("Output filename: ") inputFile = open(inputFileName, "r") outputFile = open(outputFileName, "w") count = 1 for line in inputFile: newLine = str(count).rjust(4, " ") + "> " + line outputFile.write(newLine) print(newLine) count += 1

4 0
3 years ago
What is one effect the internet has had on the library
Shkiper50 [21]

Answer:

The internet provides access to an abundance of information from home, making it easier for people to get answers much faster. This efficiency has caused libraries to receive less business and less users, therefore making their service less popular.

7 0
3 years ago
3 Points
tino4ka555 [31]

Answer:

its B the person in the comments were right

Explanation:

took an edge test

6 0
4 years ago
A variable of type unsigned char stores a value of 255. If the variable value is decremented, what exception will occur
solmaris [256]

Answer:

No exception will occur

Explanation:

Given

Unsigned Char

Value  = 255

Operation = Decrement

Required

What type of exception occurs?

Let's assume the variable is a.

So, we have that

a = 255

The range of values of an unsigned char a is 0 to 255

So, when a is decremented by 1, the new value of a becomes 254

254 is still within the range of 0 to 255.

Hence, no exception will (or is excepted to) occur

8 0
3 years ago
Other questions:
  • Write a program that determines the price of a movie ticket (similar to the one in the chapter). The program asks for the custom
    9·1 answer
  • Which is the main function of the arithmetic and logic unit (ALU)?
    5·2 answers
  • In the lab, the Ethernet II detail of the provided packet capture file indicated that Wireshark had determined that the ________
    5·1 answer
  • Why is it a good idea to understand what you are good at and what you enjoy
    11·2 answers
  • Which of the following statements is/are true by definition.
    5·1 answer
  • cellPhoneBill(m,tx)Write the function cellPhoneBill()that takes two int m and txas input and returns a float.The function takes
    11·1 answer
  • Name criteria used when selecting a printer
    10·1 answer
  • Which type of RAM is used exclusively in laptops?<br> a) SODIMM<br> b) DDR3<br> c) DDR<br> d) DDR4
    15·1 answer
  • Important tools used in the _____ phase of the DMAIC process include a project charter, a description of customer requirements,
    10·1 answer
  • What is your favorite coler and what do you like to do and
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!