C++ :: Code For Digital Clock - Adding While Loop?

Aug 23, 2013

This is my code for a digital clock. It only refreshes when i type in a letter.

#include <iostream>
#include <ctime>
#include <iomanip>
using namespace std;
//char dateStr [9];
char timeStr [9];
char almtimestr[9];

[code]....

View 3 Replies


ADVERTISEMENT

C/C++ :: PC Based Digital Clock Via Parallel Port

Dec 11, 2012

I have this project and I already have a code and the circuit, but I studied assembly language it's supposed to display the hours and minutes.

Here's the code:

TITLE CLOCK.ASM
    DOSSEG
    .MODEL SMALL
    .STACK 0100H
    .DATA
    PRINTERPORTBASEADDRESS equ 378h

[Code] ....

This is the circuit diagram [URL] ....

View 7 Replies View Related

C/C++ :: Eclipse Terminating Executable After Adding A Bit Of Code

Feb 3, 2014

I have the following code

#include "../header/FileIO.hpp"
#include <fstream>
#include <stdexcept>
#include <iostream>
std::string FileIO::ReadTXT(std::string filePath){
std::ifstream input(filePath.c_str());

[Code] ....

When I run it in Eclipse, it does not open an SDL window, and simply says <Terminated> Test.exe [C/C++ Application]. I can build the project successfully, but it simply won't run. There are no errors displayed.

HOWEVER, if I replace the above code with the code below, it runs fine, and creates an SDL window.

#include "../header/FileIO.hpp"
#include <fstream>
#include <stdexcept>
#include <iostream>
std::string FileIO::ReadTXT(std::string filePath) {
std::string output;
return output;
}

To make things weirder, if I run it in debug mode, even with the first piece of code, it will run and open an SDL window.

On an unrelated note, what does " Can't find a source file at "e:pgiawsrcpkgmingwrt-4.0.3-1-mingw32-srcld/../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/main.c"

Locate the file or edit the source lookup path to include its location." mean? I am using Windows 8, MinGW, GDB 7.6.1-1, G++ 4.8.1-4, and MSYS 1.0.1 with Eclipse CDT.

View 3 Replies View Related

C Sharp :: Unreachable Code Detected When Adding Switch Statement

Oct 28, 2013

I am getting an error "Unreachable code detected" when I add a switch statement.

My code looks like:

private void calbtn_click(object sender, EventArgs e) {
  double regFee;
  double lodging;
  double days;
  string Total  {
    string course;

[Code] ....

(Everything works functionally until I try to add the switch statement.)

View 2 Replies View Related

C++ :: Interfacing Digital Camera Or Webcam

Feb 27, 2013

How to to interface my digital camera or webcam with the c++ so that the camera can capture continuously when the camera or webcam detect a badminton shuttlecock. I am using Dev C++.

View 1 Replies View Related

C++ :: Adding Reciprocals Of The Numbers From 1 To 10 - Loop

May 2, 2014

How to do the problem below using loop?

Using loop...

Output the total of the reciprocals of the numbers from 1 to 10:

1/1 + 1/2 + 1/3 + 1/4 ... + 1/10 = 2.928968

View 3 Replies View Related

C++ :: Adding Up Values Of Dice Rolls In A While Loop

Feb 19, 2013

I'm having a problem adding up the values of the dice rolls in a while loop. The program will only store the last value so how would I get it to store multiples values? Here is my program thus far. I would try an array but we haven't gotten to that yet.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
int die_1=0, die_2=0, total_score1, total_score2, player1score;
char enter;

[Code] ....

What operators or equation I should use to accomplish this?

View 7 Replies View Related

C++ :: How To Print Any Input Year In Digital Block Form

Apr 29, 2013

How to print a year like DIGITAL CLOCK NUMBER for any input four digit number ...

For example if input 1000 the output should be 1000 but each number should look like this in the block form for example number 0 is, don't mind those stars, i did not know to print it here, that is number zero ...

======
=****=
=****=
=****=
======

View 1 Replies View Related

C# :: Fibonacci Series - Adding Value In Array Inside While Loop

May 27, 2014

I am making a program to run Fibonacci series. I have created 2 array.

1)- 1st array holds only 0, 1
2)- 2nd array holds other values eg: 1, 2, 3, 5..........etc

I am using while loop to get the febonacci series and storing it in a 2nd array called int[] numbers.

After getting value using while loop, I am joing both the arrays using int[] final = arr.Concat(number).ToArray();

At last, I have used foreach loop to add the febonacci series into the listbox.

The problem I have is that, I cannot able to concat both the arrays. I tried to assign number array at the top of the while loop. so that number variable will be accessible outside the while loop. But I am getting a error.

See the code below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

[Code] .....

View 4 Replies View Related

C :: Getting Fixing Loop With Code

Mar 31, 2013

I want the 'counter' loop to go through twice, each time reading in 15 characters from the standard input, then going through the evalutor

Code:

#include <stdio.h>
#include <ctype.h>
int main (void)
{
char inputtedhand[64];
int NumC=0, NumD=0, NumS=0, NumH=0;
}

[code]...

View 9 Replies View Related

C++ :: How Does Clock Return Same Value Every 72 Minutes

Apr 19, 2014

I am reading up on the clock() function: URL....It states: "On a 32bit system where CLOCKS_PER_SEC equals 1000000 this function will return the same value approximately every 72 minutes."

How could this return the same value, if clock is the number of clock ticks elapsed since program execution. Wouldn't the number of clock ticks continue to grow, and as such, when we divide by 1000000, the return value should continue to grow. So how does this function return same value every 72 minutes?

View 2 Replies View Related

C++ :: How To Change Clock Time

Nov 28, 2013

The system clock starts once the system is executed. But how can I update the clock value to certain other value? Let say, for example. If a=10, then, immediately the clock is set to 10 seconds after the current clock time. Is it possible?

View 1 Replies View Related

C++ :: Operation Time Or Clock Cycles?

Apr 21, 2014

So I am making a game and I want to push performance to the limit. That's why I really want to know how many clock cycles every operation, cast, memory allocation - EVERYTHING takes. Or approximate time consumption ratio, anything like that.

I tried doing it myself: I created a timer based on clock cycle counting, measured time of an empty loop and the same loop with various operations inside, but the results were extremely inconsistent and confusing: empty loop would take more time that the same loop with an addition, the time would vary greatly,... I guess it's because of background operations using up some of the CPU...

Since I didn't manage to find anything on the internet I guess there might be something I'm missing: maybe it depends on the processor?

View 4 Replies View Related

C++ :: How To Add A Loop / User-defined Function And Array / Structure To Code

Apr 24, 2012

We had to write a "selling program for computers, laptops and tablets", which I did but for the extra credit, we have to have those three points in the application and I have tried but how to do the "extra credit" part, which I really need.

1.) A loop to prompt the user if they would like to place another order

2.) At least one user-defined function

3.) An enumerated data type, array or struct (structure)

I did one of these three, it's a "DO WHILE" loop asking users if they want to make another order, it's right at the beginning of the code.

Code:

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
double desktop();//function prototype
double laptop();
double tablet();

[Code] ....

View 2 Replies View Related

C++ :: Sleep Function When Drawing Analog Clock

Jan 19, 2015

Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().

OK, I wrote below code. It is in its primary stages and has not been completed yet.

#include <GUI.h>
#include <time.h>
#include <iostream>
using namespace Graph_lib;

[Code] .....

I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.

View 5 Replies View Related

C++ :: For Loop - Code Puts Out Switch Statement 5 Times With Random Number

Jan 26, 2014

I am writing for loop with a switch so that scores can be inputted in by a judge. The issue that I am running into is that I will put out an the text then the test happens and the code puts out the switch statement 5 times with random number. Here is what I have written.

Code:
int main() {
int diver;
int option;
int Judge;
cout << "Enter Divers Name:";

[Code] ....

View 4 Replies View Related

Visual C++ :: Drawing Analog Clock - Sleep Function

Jan 19, 2015

The question says: Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().

OK, I wrote below code. It is in its primary stages and has not been completed yet.

Code:
#include <GUI.h>
#include <time.h>
#include <iostream>
using namespace Graph_lib;
//---------------------------------
class Dynamic_clock : public Window {

[Code] .....

I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.

[URL] ....

View 14 Replies View Related

C++ :: Function That Makes Shows Time Entered In Clock Format

Mar 11, 2014

Program should continually have user enter a positive integer, and quits on zero entered. This entered number represents the total number of seconds and after each number is entered a function is called that displays the time in hours, minutes and seconds. Sample output is as follows:

Enter Total Seconds --> 3605 1:00:05

The function needs only one value parameter and should return nothing back to main. If the minutes or seconds are a one digit number then make sure to display a leading zero as the example above shows.

Here is my program. my question is how do i make the numbers appear like this? 1:00:05

#include <iostream>
#include <iomanip>
using namespace std;

[Code].....

View 6 Replies View Related

C :: Print Out - Array Code And Pseudo Code?

Apr 15, 2013

I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.

View 2 Replies View Related

C++ :: Reducing Code Duplication From Common Code Calling Common Class

Apr 13, 2014

I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.

However, Is designing a complete class just for a few functions over kill?

Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?

View 4 Replies View Related

C :: Loop Does Not Work And Program Quits Without Displaying For Loop Function

Oct 13, 2014

We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.

View 11 Replies View Related

C# :: Use Loop To Load Two Forms Back And Forth Then Stop At Loop 4

Feb 15, 2015

I have tried to submit this topic before but i didn't submit my whole code and it was removed. So here it is. All I am trying to do is load form2 from form1 then back to form1 from form2 for a certain number of times the get out of the loop. I am new to C-Sharp and it seems as though I cant seem to figure out a way to do this.

Here is form1 and form2 code. I have commented out a few things I have tried.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

[Code]....

View 3 Replies View Related

C :: Extra Loop Being Executed In Do-while Loop

Jul 1, 2013

Code:
#include <stdio.h>
#include<ctype.h>
void try5t(){

char choice;
int choiceint;

[Code] .....

Loop is repeated an additional time as shown in the screenshot:

View 9 Replies View Related

C++ :: Adding Two Or More Strings Together

Nov 16, 2013

I tried to add 2 or more strings together but failed.

eg I would like to add "KK" & "LL" together by adding but it couldn't work.

string string_B = "KK";
string string_C = "LL";

string_A = string_B + string_C;

View 2 Replies View Related

C++ :: Total Is Not Adding Up?

Jan 14, 2015

Every time I run if(color=="1") it's supposed to add 1 to redTotal. However, every time I run if(color=="1") if get 1 for redTotal every time.

(Write a program that provides the option of tallying up the results of a poll with 3 possible values. The first input to the program is the poll question; the next three inputs are the possible answers. The first answer is indicated by 1, the second by 2, the third by 3. The answers are tallied until a 0 is entered. The program should then show the results of the poll—try making a bar graph that shows the results properly scaled to fit on your screen no matter how many results were entered.)

Code:
#include <iostream>
#include <string>
using namespace std;
int main()

[Code]....

View 4 Replies View Related

C :: Adding New Functions

Jul 3, 2014

I am new to c and I have come across a problem when adding other functions to a programme and printing the values. The question I am attempting to solve is :

The following function computes ex by summing the Taylor series expansion to n terms. Write a program to print a table of ex using both this function and the exp() function from the math.h library, for x = 0 to 1 in steps of 0.1. The program should ask the user what value of n to use.

double taylor(double x, int n) {
int i;
double sum = 1.0;
double term = 1.0;
for (i=1; i<=n; i++) {
/*Or we could have written: */
term = term * x / i; /* term *= x / i; */
sum = sum + term; /* sum += term; */
}
return sum;
}

My code is

Code:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
/*Taylor series for e*/

[code]....

code prints out the values for exp, but it gets stuck in the Taylor function and I'm not sure how to solve it.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved