How to program print a one-year reminder list

Assignment Help Programming Languages
Reference no: EM13322194

(a) Have the program print an error message and ignore a reminder if the corrsponding day is negative or larger than 31 (using the continue statement)
(b) Allow the user to enter a day, a 24-hout time, and a reminder. The printed reminder list should be sorted first by day, then by time. (The original program allows the user to enter a time, but it's treated as part of the reminder)
(c) Have the program print a one-year reminder list. require the user to enter days in the form month/day.

Here is the given program (I sure hope this pastes correctly):

#include "remind.h"

/* Prints a one-month reminder list */

#include <stdio.h>

#define MAX_REMIND 50 /* maximum number of reminders */

#define MSG_LEN 60 /* max length of reminder message */

int read_line(char str[], int n);

int main(void)

{

char reminders[MAX_REMIND][MSG_LEN+3];

char day_str[3], msg_str[MSG_LEN+1];

int day, i, j, num_remind = 0;

for (;;)

{

if (num_remind == MAX_REMIND)

{

printf("-- No space left --\n");

break;

}

printf("Enter day and reminder: ");

scanf("-", &day);

if (day == 0)

break;

sprintf(day_str, "-", day);

read_line(msg_str, MSG_LEN);

for (i = 0; i < num_remind; i++)

if (strcmp(day_str, reminders[i]) < 0)

break;

for (j = num_remind; j > i; j--)

strcpy(reminders[j], reminders[j-1]);

strcpy(reminders[i], day_str);

strcat(reminders[i], msg_str);

num_remind++;

}

printf("\nDay Reminder\n");

for (i = 0; i < num_remind; i++)

printf(" %s\n", reminders[i]);

return 0;

}

int read_line(char str[], int n)

{

int ch, i = 0;

while ((ch = getchar()) != '\n')

if (i < n)

str[i++] = ch;

str[i] = '\0';

return i;

}

Reference no: EM13322194

Questions Cloud

Fire detection system by security safety : Kuznicki made a contract for the installation of a fire detection system by Security Safety Corp. for $498. The contract was made one night and canceled at 9:00 the next morning.
Write a program that simulates battle between a cat and mice : I have written the program for the below assignment, but I am not getting the correct output. Below is the assignment and the program I have written along with the output I get.
What is length of consecutive wet days that has a occurence : Assuming that the number of days until the next dry day is geometrically distributed, what is the length of consecutive wet days that has a probability of occurence of no more than 0.05
What is probability that one can travel to city three : There are two ways to get from City One to City Three, (a) directly or (b) via City Two. Let A be the event that the road from City One to Three is open. Similarly, B is for City One to Two and C is for City Two to Three.
How to program print a one-year reminder list : Have the program print an error message and ignore a reminder if the corrsponding day is negative or larger than 31 (using the continue statement)
How hard and what direction must you pull on the third rope : One of your friends pulls on a rope with 3 units of force and other pulls on a second rope with 5 units of force, How hard and what direction must you pull
Where will the final image formed by second lens be located : Two 29.0%u2212cm -focal-length converging lenses are placed 14.0cm apart. An object is placed 39.0cm in front of one lens. Where will the final image formed by the second lens be located
Part of an investigative study on supermarket advertising : Three supermarket chains in the New York area each claim to have the lowest overall prices. As part of an investigative study on supermarket advertising the New York Daily Post conducted a study. First, a random sample of nine (9) grocery items was s..
What is the probability that the period is more than 15 min : The van leaves as soon as 6 people have arrived. On average, 24 passengers arrive each hour. What is the probability that the period between bus department is more than 15 minutes.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd