C :: Program Which Calculate Time Difference Between Two Daytime
Jul 4, 2013
I'm challenged to write a program which calculates the time difference between two daytime.
compiler doesn't give an error, yet the warning: "format '%d' expects argument of type 'int *', but argument 3 has type 'int' [- Wformat]" for lines 24 and 26
However, by entering the first time the program crashes anyway. so I assume I do really need some pointer to make it read from the console can you see where my problem is?
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int Second;
int Minute;
int Hour;
}Time;
It is supposed to calculate and graph time vs. distance. The problem I have is graphing, if I put too small values for Vi, which is the initial velocity, it just graphs one or two points, because t is too small. I already tried to adjust t with 'if(t<10) t=t*10; if (t>100) t=t/10;', But it seems not to solve my problem.
Other truble I have is that, as the graph is parabola, core values are very close together, and when plotted, these values are in the same line on the screen.
Here is my code: #include<stdio.h> #include<conio.h> #include<math.h> void main() { float x, y, hmax, t, amax, vi, v, a, b, g, ang; /*x= x coordinate, y= y coordinate, hmax= maximum height,
I'm trying to create a program to calculate the flight time and fuel burn of an airplane. However when I repeated the whole calculation, it did not show any data or result like the previous calculation. In addition, the "If" statement that I used to test the "fuelRemain" doesn't work properly. I can't figure out why.
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?
I need to get the current time, have the system sleep for a period of time, then return the difference in seconds.
#include <iostream> #include <string> #include <ctime> #include <time.h> #define _CRT_SECURE_NO_WARNINGS using namespace::std; // in the <ctime> library is a function time(0)
[Code] ....
I'm not receiving an errors but the return value is not correct. It's returning 1.4259 no matter how long it sleeps for.
I looking for method which can give me the height difference of an AVL_tree.
The method i come up with up now is this.
int avl_tree::balance(node* pointer) { while (pointer->left != NULL) { int left = balance(pointer ->left); } while (pointer->right != NULL) { int right = balance(pointer->right); } return left - right; }
Which recursively calls itself, but the problem is that i get stuck on the first line..
I want to calculate processing time in milliseconds as most of function I found give me in second. I am new user to C++, the code will be running under linux.
define the time and space complexity of an algorithm and about what can i do when the time and space complexity are given and i should write the code corresponding to the restrictions , which i find very difficult.
I have been trying for several months to create a simple SNTP single Client/Server based on RFC5905. Finally I manage to make it work at least I think it works correctly, but when I tried to test my code against a real NTP server (e.g. 0.se.pool.ntp.org:123) the timestamps that I am receiving need to be recalculated. I have tried several different approaches but no matter for 3 days now but no matter what I tried nothing yet.
The problem that I am having in not so much programming error is more about knowing how the NTP server operates.
How to convert the NTP timestamp to Unix epoch timestamp?
Syntax to execute the Server e.g. ./server 127.0.0.1:5000 and Client e.g. ./client 127.0.0.1:5000
Syntax to execute the Client against a real NTP server e.g. ./client 0.se.pool.ntp.org:123
Im just wondering how would i get a formula to calculate the total size and proportion of how far the media player has been played, in proportion with the size of the sizeable form, i need an int for the:
Width of formLength of movieHow long has been played by user
I have this code so far:
//The current position played! - Within the timer.tick event arg! string splayed = axWindowsMediaPlayer1.Ctlcontrols.currentPosition.ToString().Split('.')[0]; int iplayed = Convert.ToInt32(splayed + 1); //The total time of the movie/audio. string stotal = axWindowsMediaPlayer1.Ctlcontrols.currentItem.duration.ToString().Split('.')[0]; int itotal = Convert.ToInt32(splayed);
[Code] ....
I have the "AxWindowsMediaPlayer" reference installed, but i need to know how it would work...
The following code prevents windows from letting the monitor go into sleep mode when the program is active and wakes the monitor up after a scanner scans something.
When the program is started normally it works fine. But when the program is started from a network share it goes to sleep anyway and the OnScan does not work anymore. Removing the Send Message line makes On Scan work again but then the monitor wont wake up on a scan of course.
What could be the problem here when started from the network?
My tasks was to write a program which finds difference between two arrays (elements which are in first array but not in second and vice-versa). Program works, but something wrong is with the memory allocation for array.
My code is: main.c Code: #include <stdio.h> #include <stdlib.h> #include "header.h"
I need to make a program which solove difference between two interested times in format hh:mm i made it but it doesn't give me right answers for all times for example it can't solve times like 23:50 and 0:15 and it says that difference is 23:35 and no 00:25
I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2
Here is my code
#include <iostream> #include <cmath> using namespace std; int main() { int weight; int height; double BMI;
So my midterm exam for programming is done. My program didn't run. Tried rewriting it once I got home. I am still getting an error that the program could not be run. Also, we weren't allowed to use the internet. So I didn't know how to calculate for the discounted rate.
I am using Microsoft Visual Studio 2010.
Given problem:
ABC Hotel offers 5-10% discounts depending on how much money has the user spent. If item purchase is lesser than 1000php (1USD is 43.19PHP) 5% discount is availed. Greater than 1000php then 10% discount is availed. Total price and discounted price should be displayed.
#include<iostream> using namespace std; main() { float a,b,c,d,e,f,g,h,i,j,total,discounted_price; cout<<"Please input price of first 1st item: ";
I am an IT college student and this is a self-assigned project i have done in an attempt to learn programming in C AND at the same time how time scheduling of an OS works (Both done in order to prepare for upcoming semester exams) using FCFS ,SJF, RR and PS algorithms (planning on adding SRT too sometime soon). (took me 9 hours total work time including validations). What i wanna know is from more seasoned coders if i am on the right track. *cross fingers*
Also is there a way to display the time only instead of the date? How will i change the program to display the time in standard 12 hours, instead of 24 hours?
#include <iostream> #include <time.h> using namespace std; int main() { time_t tim; time(&tim); cout << ctime(&tim); }
void input (int array[20]); //Used when user inputs the numbers. void calculate(int array[20], int *pairs); //Used to calculate the matches. void output(int *pairs); //Used to output the number of pairs.