C :: Enter Date - Calculating Next Day
Mar 14, 2013
Currently I am working on a program where you enter in a date 14 03 2013 (Day, Month, Year) and you get the next day. I seem to be coming stuck with months with less than 31 days, and the whole leap year thing. Here is my code so far.
Code:
#include <stdio.h>
int day, month, year, next_day, next_month, next_year, calculation;
int main() {
printf("Enter a date in the form day/month/year: ");
scanf("%d %d %d", &day, &month, &year);
[Code] .....
View 4 Replies
ADVERTISEMENT
Apr 2, 2013
I want to create a program where you enter today's date, in the following format: 02/04/2013. As well as your birth date in the following format: 27/09/1994. After doing that I want to assign the day, month and year of the present date, as well as the day, month and year of the birth date in to their own variables (for example, Day, Month, Year), and then calculate your age.
I have tried doing this with cin.get(), but this method is way too long, and I'm looking for a shorter method
View 2 Replies
View Related
Dec 4, 2014
I don't know how to ask the user to enter the date in this format (DD/MM/YY) and ISBN number with hyphens.
After user enter date and ISBN number, it should look like this:
Date: 5/24/12
ISBN: 0-000-12345-0
#include <iostream>
#include <string>
using namespace std;
int main() {
string date;//MM/DD/YY Format
[Code] ....
View 7 Replies
View Related
Oct 11, 2012
i'm making a program that, given a person's birthdate or any other date, will display the day of the week of the person was born.
There is this part where it says "use a switch statement to make this calculation, If desired month is 12, add the number of days for November, if desired month is 11 add the number of days for october....
So it's suppose to start with "case 12 :...
I can't figure out what to write for the statement....
View 6 Replies
View Related
Mar 28, 2014
I have two date/time structures which I'm populating, but when I populate the second one it sets the same values in the first. This is what I've got so far
tm *FirstDate = gmtime(&now);
tm *SecondDate = gmtime(&now);
cout <<"Enter your first date in the format dd/mm/yyyy" << endl <<">";
getline (cin,tempstring);
[Code] .....
View 2 Replies
View Related
Nov 29, 2013
Finally got a programme partially working, why the values are not showing? Is this down to incorrect formula or i havent declared the values etc?
Code:
#include <stdio.h>
#include <math.h>
float timeconstant(float R, float C);
float R;
float C;
float time_c;
[Code] ....
View 2 Replies
View Related
Oct 21, 2013
I've been trying to calculate the Second standard deviation but the average in the second loop isn't calculating correctly which is causing the standard deviation (method 2) to not calculate correctly. I can't find anything wrong.
Code:
#include <iostream>#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
usingnamespacestd;
int main ()
[Code]...
View 8 Replies
View Related
Feb 19, 2014
As part of a project i want to display the speed of a small wheel on a 7 segment display. I am using a hall effect sensor to pick up the pulses of the rotation. I am not sure how to write a programe on C to calculate the RPM from this....
View 4 Replies
View Related
Sep 28, 2014
I am having trouble with my C++ program. My program asks the user to enter any number greater than 0 and less than 20, and if the user enters any number(s) outside the acceptable range, the output should display:
input outside of exceptable range > 0 and < 20
length: 1 width: 1 area: 1 perimeter: 1
But in my program, this output displays no matter what the user types (even if the numbers are in the acceptable range, when it should be displaying the length and width the user enters and also displaying the calculated perimeter and area whenever the user enters number(s) in the acceptable range. Here is my code:
#include <iostream>
using namespace std;
float class_rectangle_area();
float class_rectangle_perimeter();
float class_rectangle_length();
float class_rectangle_width();
[Code] .....
View 4 Replies
View Related
Dec 4, 2013
I am just learning arrays, I modified my program to use arrays but now it wont calculate the gross pay well it seems it does but not correctly. The gross pay is coming back as "-9.25596e+061" it worked fine before I added arrays. I do have a text file with the following input :
John Doe 1404 45 20 H
Bobby Jill 1404 45 20 S
#include <iostream>//including library (directive header file)
#include <windows.h>//makes console look pretty
#include <fstream>//Library to read files
#include <iomanip>
using namespace std;
int main() {
SetConsoleTitleW(L"Payroll System");//Set Console Title
[Code] .....
View 2 Replies
View Related
Mar 5, 2014
I want to find out the time difference,say i start walking from my home at 23 hr 10 min 25 seconds and I reach destination at 1 hr 10 min 25 seconds.. I know here the time difference is 1 hr 55 min 55 seconds. But how am I gonna calculate this?
View 3 Replies
View Related
Jun 13, 2014
I have a problem with calculating the CPUtime. I am using CPLEX to solve linear programming with 3 diferent algorithms.
1-primal Simplex
2-Dual Simplex
3-Barrier Method.
When I am trying to use Barrier method, my clock does not give me a right processing time. I don't have any problem with the other two methods. The value I am getting from ticks2 is 0 when I am using Barrier solver unlike the two other methods that I am getting some small values (ticks1 is fine). Using time_t ticks1 , ticks2 and time(&ticks1) and finally difftime(ticks1,ticks2) also gives me an integer number which is not precise enough. I need a way to compute cputime with accuracy of at least 2 decimals.
clock_t ticks1,ticks2;
double solvingtime
if (solver.primopt==1){
ticks1=clock();
status=CPXprimopt(myEnv, myLP);
ticks2=clock();
[code]....
View 1 Replies
View Related
Dec 10, 2014
Write a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The data in the output file will be nearly the same as the data in the input file except that you will print the names as last_name, first_name and there will be one additional number at the end of each line: the average of the student's ten quiz scores.
The output file must be formatted such that first and last names appear together in a left justified column that is 20 characters wide where the last name comes first, then a comma and a space and then the first name. Use your read string function to read each name separately and then put them together into a larger correctly formatted string before trying to output them. Each quiz score should be listed in a right justified column that is 4 characters wide, and the average should appear in its own right justified column that is 10 characters wide.
Note that if a student has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10; these students are assumed to have missed one or more of the quizzes. The output file should contain a line (or lines) at the beginning of the file providing appropriate column headings.
This is how much I have so far:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char* read_string(char* buffer, int max_size, FILE* fp);
int main(int argc, char *argv[]) {
FILE *fp_input, *fp_output;
[code]....
View 7 Replies
View Related
Nov 20, 2014
my code is working as expected except a slight error, i have to find min max and median values of an inputed array terminated by 0, the problem im having is with calculating the minimum, where when i enter 0 to terminate the program it uses 0 as the minimum value. my code is as follows
public static void FindAverages()
{
try
{
[Code]....
View 3 Replies
View Related
Apr 3, 2014
I wrote a function to calculate the hypotenuse of a triangle. My code looks fine but when i enter the two sides it does not give out the right answer. I really don't know what to do.
#include <stdio.h>
#include<Windows.h>
#include<math.h>
double hypotenuse(double side1, double side2);
int main(void){
double side1, side2, hyp;
[Code] .....
View 8 Replies
View Related
Mar 16, 2013
When I compile my code with g++ I get the error: constructor, destructure or type conversion missing before sum.
int sum(int,int);
void sum(int,int,int&);
main()
sum (v) // This is the line that the compiler is reporting the error occurs.
answer sum()
int main(){
int a=1;
int b=2;
int sum;
[Code] ....
View 12 Replies
View Related
Jul 1, 2013
I'm trying to determine the first Tuesday of any month in a given year.. I'd prefer to use my own functions to arrive at a solution, but logically I could sorting these things out.
View 6 Replies
View Related
Feb 23, 2013
As homework we were assigned to enter the following code to calculate the distance between two points on the x and y plane. The program should ask the user to enter two points then should calculate the distance between two points and print the distance on the screen.
My program will compile correctly but when attempting to run the actual program it doesnt do anything and some how completely skips over my main function...
Code:
#include <stdio.h>
#include <math.h>
struct point {
float x;
float y;
[Code] ....
View 2 Replies
View Related
Jan 24, 2013
I have a question. I would like to actually have some measure of roughly how long it takes to do a fwrite to a drive. When I do the following:
clock_t begin = clock();
unsigned long long size_t = fwrite(send, 1, transfer_size*sizeof(unsigned long long), wpFile);
clock_t end = clock();
double long elapsed_secs = double long(end - begin) / CLOCKS_PER_SEC;
Unfortunately, I don't get any different result for different transfer size!!!
My guess is that the clock_t , once it issues a fwrite command, some how stops its measurement, and it comes back again, when I am already done with fwrite. I do get the almost same measure, whether my transfer size is 32KB Byte or 16MB ! Which I was indeed expecting to see a huge difference. I wouldn't really want the exact real timing measure (well off course it will be nice to know); and all I care about is to see some difference in time whether I am doing KB transfer vs MB transfer.
Some rough measurement required of the actual time being elapsed for fwrite function?
View 10 Replies
View Related
Jan 22, 2014
How do to calculate the following equation"5+((56+8)/2)" using expression builder
Note: the equation may change "50+((26+8)/12)"
View 1 Replies
View Related
Mar 21, 2014
Here's my attempt:
input.open(name);
if (input.fail()){
cout <<"Error opening file"<<endl;
}
while (input>>numbers)
{
counter++;
total += numbers;
[Code]...
Copy of the output:
Error opening file
The Standard Deviation of all the numbers is: -9.25596e+061
Press any key to continue . . .
Its not giving me the right answer.
View 1 Replies
View Related
Jul 20, 2014
I have two doubts in the following code,the doubts are marked..PLs note that the following code is correct .This is a program to read 2d array using pointer ()i.e Dynamic array ,to calculate its rowsum and column sum and display this array along row sum and column sum.
#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
int *Val,*Rsum,*Csum;
int MaxR,MaxC,i,j;
[Code] .....
View 2 Replies
View Related
Mar 28, 2014
Write a function which takes two parameter of integer type and both parameters are positive integer. These number should be provided by the user of your program. The first parameter is lower than the second parameter. You function should be able to calculate the sum of the square of each of the numbers between the two inputs and should display that. Please write a main function to display the working of your function. Call the function at least three times by using some loop in the main function.
This is what I came up with but it is not correct:
#include <iostream>
using namespace std;
void sumsquares(int number1, int number2) {
int sum = 0;
for(int i = number1; i<number2; i++)
sum =sum+ i*i;
cout<<"The Result is: "<<sum<<endl;
[Code] .....
View 2 Replies
View Related
Nov 18, 2014
So I am currently in the middle of learning c++ and I decided to jump ahead of the book and tried to do add procedures. My goal is to have main calling other procedures such as welcome message().
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#define MIN_HOURS 0.00 // minimum hours per week
#define MAX_HOURS 60.00 // maximum hours per week
#define MIN_RATE 0.00 // minimum pay rate
#define MAX_RATE 99.99 // maximum pay rate
[Code] .....
View 5 Replies
View Related
Jan 12, 2013
I have written the following function to calculate GCD of floating point numbers, but when I run this for (111.6, 46.5), the calculation of fmod(a,b) in the funciton starts giving the wrong result after 2 recursive calls. I am unable to find the error here.
float gcd(float a, float b){
if (a>b) {
if(b==0){
[Code]....
View 1 Replies
View Related
Jun 20, 2014
I am getting this weird error when calculating sums. Here is what my program does: it generates two random numbers and then randomly puts either an addition or subtraction sign between the two and then I am asked to enter what the correct answer for that question is. But on some of the subtraction questions when I give the answer it says I got it wrong after which the program shows the right answer. What's confusing is that the answer the computer calculates is the same that I entered. Anyways the complete program and a screenshot of the console window which shows the error are below. The function in question here is decAddSub at line 54. The error is shown in the first sum in the output window. It doesn't affect addition problems and only affects some of the subtraction problems.
#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<random>
[Code].....
View 2 Replies
View Related