I need help writing this program in C.
(not C++)
HI please find the answer
If you have any query please let me know first i will give solution
==============================================================
Your program in c
#include <stdio.h>
// function that return int
// and take a parameter month, date, and year
int valid_date( int mm,int dd, int yy) {
// if month is less than 1 and greater than 12
// return 0
if (mm < 1 || mm > 12) {
return 0;
}
// if date is less than 1 then return 0
if (dd < 1) {
return 0;
}
// declare variable days and initalize value to 31
int days = 31;
// if month is 2 i.e febuary
if (mm == 2) {
days = 28;
// check the leap year
// in this year the number of day in febuary is 29
if (yy % 400 == 0 || (yy % 4 == 0 && yy % 100 != 0)) {
days = 29;
}
}
// check the month which has 31 days in month
else if (mm == 4 || mm == 6 || mm == 9 || mm == 11) {
days = 30;
}
// if dd greater than days like 2, 29, 30, 31
// then return 0
if (dd > days) {
return 0;
}
// othewise return 1 if condition is true in all case
return 1;
}
// main function
int main(){
// declare a variable
int flag;
int dd,mm,yy;
// print the text
printf("Welcome to my Date Checker Project\n");
printf("Enter the date to test as : MM/DD/YYYY ");
// take the user input
scanf("%d/%d/%d",&mm,&dd,&yy);
// finally call and print the valid_date function by passing dd, mm and yy in it.
// this function return the value in 1 for valid date
// and 0 for not valid date
// and store in variable flag
flag=valid_date(mm, dd, yy);
// here check the flag
// if conditon is true then return valid
// otherwise false i.e not valid
if(flag==1)
{
printf("The date is valid" );
}
else
{
printf( "It is a bad date");
}
}
==================================================
Output
Test1
Test2
test3
=============================================
If you have any query please let me know first i will give solution
I need help writing this program in C. (not C++) Armor Games CrazyMonkeyGames Max Games Palomar...
Need help writing beginner C# program, I will make sure to
provide feedback to whoever can help me figure it out!
No public or global variables should be used. You need to
consider passing arguments between the methods according to the
ways described in the lecture. i.e. all variables should be
declared inside the methods and passed to other methods by
value/ref/out as needed
Description: We want to design a Date class to represent a date using three integer numbers...
C Program Question 1: Write a program that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...
Question 1: Write a program in C that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...
C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...
please write C++ code to finish R0,R1,R2
Introduction In this assignment, you are going to develop a "Schedule Book System that runs in the command line environment. The system stores the schedule of events input by user and allows users to add view or delete events. You can assume that the system can at most store 100 events Each group is required to write a Win32 Console Application program called ScheduleBook.cpp The requirements are listed below. RO When the program...
The assignment : Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate multiplier: 5.2252 Highway multiplier: 9.4412 Residential multiplier:...
Write a program called RentalRate.java which reads in a date of birth, today’s date and a male/female designation from the user, and will then determine the basic daily and weekly rates for rental of an economy class car. Rental rate classes are: Best rate (male drivers, age 33–65 and female drivers, age 30-62)--$40.00per day, $200.00 per week Risk rate 1 (female drivers, age 25–29)–Best rate plus $10.00 per day or best rate plus $55.00 per week. Risk rate 2 (male...
I need help with this assignment in C++,
please!
*** The instructions and programming style details
are crucial for this assignment!
Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...
I need help with my coding for C++! The goal of this is to calculate the total cost of a product by combining the products price and the amount of tax, then display it to the user. The numbers we have to test out is 100 for the price and 8.25 for the percentage. When I test is out, the formula works but it isn't rounding the 108.25 to 108.3, which is the total price we are supposed to display...