C :: Execution Stopped Every Time Try To Add Data From Scanf

Nov 12, 2013

this is a syntax i've been trying to run. apparently it stopped as i entered the first value. this is the value i am trying to key in

Initial House Cost 67,000 62,000 75,000
Annual Fuel Cost 2,300 2,500 1,850
Tax Rate 0.025 0.025 0.020

my syntax are as below

Code:

#include <stdio.h>
#include <conio.h>
int main(void) {
float houseInt1 , houseInt2 , houseInt3 ;
float fuelAnnual1 , fuelAnnual2 , fuelAnnual3;
float taxRate1 , taxRate2 ,taxRate3;
float total1 , total2 , total3;

[code]....

View 9 Replies


ADVERTISEMENT

C/C++ :: Round Robin Execution With Gantt Chart - Arrival Time And Burst Time

Mar 10, 2015

This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??

#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;

[Code] ....

View 2 Replies View Related

C++ :: Execution Of Certain Commands - Setting Device Time

Sep 10, 2013

I got a assignment in which i have to write codes for execution of certain commands.

One of the command is set_time. if user enters set_time 12:12:12

The time should get reset to 12:12:12 no matter what it is now.

View 7 Replies View Related

C Sharp :: Counting Execution Time Of A Task?

Nov 9, 2013

I am checking out this simple piece of code:

private void button1_Click(object sender, EventArgs e)  {
            Stopwatch sw = Stopwatch.StartNew();  
            Task Task1 = Task.Factory.StartNew(() =>  {
                    Console.WriteLine("Task1 started in : "+ " "+sw.ElapsedMilliseconds);
                    Thread.Sleep(4000);
                    Console.WriteLine("Task1 finished in : " + " " + sw.ElapsedMilliseconds);
                }
                );
        }

and the results are :

Task1 started in : 2 in milliseconds
Task1 finished in : 4015 in milliseconds.

The problem is, that if i count the time with an external device, just like the timer of my watch or my cellphone s,the total time is 4,8 or 4,9 seconds, which i wouldn t expect that to happen.

The first thing i ve thought, is that it takes the ThreadPool about 800msec or 1 sec to create the thread so as to execute this task, but even if it is so, shouldn t the stopwatch count the time precisely?So , why is there a deviation between an external timer and the stopwatch ?

View 1 Replies View Related

C++ :: Measuring Execution Time Of Static And Dynamic Binding

Jan 11, 2013

consider the code bellow

#include<iostream>
#include<ctime>
#include<boost/progress.hpp>
using namespace std;
class parent {
public:
virtual void dynamic_display(){

[Code] ....

I am getting the following as output

Calculating....Static Function is called1times
The number of processor clicks is0time is0
Calculating....Dynamic function is called1times
The number of processor clicks is0time is0
Static Function is called2times
Dynamic function is called2times
Static Function is called3times
Dynamic function is called3times

I am actually trying to calculate the time to execute a statically binding method and a dynamically binded one.consider only the first four lines in my output. Why am i not getting the actual result.

View 3 Replies View Related

C/C++ :: Sequential Matrix Multiplication - Error In Execution Time

Apr 30, 2014

I wrote program for Sequential matrix multiplication .But after execution for any input value( ex. 100,150,400) it shows the execution time is 0.000 msec.

#include <stdio.h>
#include <math.h>
#include <sys/time.h>
void print_results(char *prompt, int N, float *a);
int main(int argc, char *argv[])

[Code] ......

View 2 Replies View Related

C :: How To Exit Out Of Scanf After Certain Amount Of Time

Oct 25, 2014

I'm trying to make a very simple reaction game where a random number flickers on the screen for a fraction of a second and the user has to then enter the number before another comes on the screen after a random amount of time. However I dont know how i would make it so that the user cannot enter anything after a certain amount of time has passed, below is my code?

Also FYI, clock_start is at 5100 because by the time the program actually gets to scanning in the first number the time is at an absolute minimum of 5050 milliseconds however obviously this is an impossible number to reach due to processing, my machine clocks in at 5080.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int main(void){

[Code]...

View 6 Replies View Related

Visual C++ :: Obtaining Actual Effective Execution Time Per Thread With Hyperthreading

Jun 13, 2013

I'm looking for a function like GetThreadTimes, but one that gives correct results in a hyperthreading CPU.

For instance, if you start 2 threads on a CPU with 1 physical core and 2 logical cores, GetThreadTimes will say that both these threads use 100% CPU.

However, in reality they only use 50% each. Is there a function that returns correct results, or is there another workaround?

View 8 Replies View Related

Visual C++ :: Read Table And Get All PNAME Into Combobox - Reduce Query Execution Time

Nov 14, 2014

My table:

Code:
Database name: test & Table name : Profilemaster
+-----+--------+
| PID | PNAME |
+-----+--------+
| 1 | APPLE1 |
| 2 | APPLE2 |
| 3 | APPLE3 |
| 4 | APPLE4 |
| 5 | APPLE5 |
| 6 | APPLE6 |
| 7 | APPLE7 |
| 8 | APPLE8 |
| 9 | APPLE9 |
| 10| APPLE10 |
+-----+--------+

I like to read the table and get the all PNAME into the combo box.

Using the below code i can read the table, but while loop takes 2 seconds to read 10 records in the Profilemaster table.
How can i reduce the reading time?

My Code is
void MainScreen::OnreadProfileName() {
CDatabase database;
CString SqlString;
CString sDsn;
CString pname;

sDsn.Format("Driver={MySQL ODBC 5.2 ANSI Driver};Server=localhost;Database=test;User=root;Password=client;Option=4;");

[Code] ....

Is any other way to reduce the query execution time?

View 6 Replies View Related

C :: Inputting Data From Multiple Lines Using Scanf?

Aug 1, 2013

How would I go about inputting data from multiple lines using scanf?

So far I have tried a loop and somehow checking for '' but can't seem to figure it out..

E.g I want to be able to scanf the ints below line by line and print them( if that makes sense) .

5 15 20 30 5 6
5 6 8 20 34
5 6 7
5 2
2 6 7 2 1 6

This is what i've tried so far, but am really lost!

Code:

int input;
while(scanf("%d", &input)){
printf("%d",input);
if(input == '
'){
continue;}}

View 13 Replies View Related

C :: Printf And Scanf - Output String Data At The End Of The Line

Dec 2, 2013

I'm trying to get this programme to work but I can't get it to output the string data at the end of the line.I have copied and pasted the line in question below but it may be a prob with the prog further down.

It reads character input ok but doesn't put one string into another or recognize when a string is quoted in a printf.

Code:
printf("%s what is your second name?
", surname, name2, name);
#include <stdio.h>
int main ()
{
char name[20];

[Code] ....

View 8 Replies View Related

C/C++ :: How To Take Data From Internet In Real Time

Apr 17, 2015

How i can take data from internet n real time i want make program wich alarm when a specific site(from my university) have a announcement...

View 6 Replies View Related

C++ :: Traffic Control Program - Output Data At Specific Time

Oct 24, 2013

I was given an assignment to create a simple program for traffic control. How should i output data at a specific time, for e.g a driver approaches an intersection, the yellow light will flash indicating that he needs to slow down and then the red light to stop before taking a route. is there any function i can use to output red light a few seconds after yellow light.

View 10 Replies View Related

C++ :: How To Boost Up Execution

Feb 23, 2013

I wrote a program to run long simulations, in one cpu core computation. During the run, I checked the cpu occupation was always around 85%.

Since my simulation took time to run. How can I boost it up to make my cpu run at 100%? Is that because my RAM is not fast enough?

info about my laptop: cpu frequency: up to 3.2 GHz. RAM frequency: 1333 MHz.

View 2 Replies View Related

C :: Possible To Call A Function During Execution?

Feb 16, 2013

I want to write a function and be able to call it during execution (say during a while(1) loop). Is this possible without having to parse an input string to extract the function and parameters I need or is that the only way?

View 1 Replies View Related

C :: Program Come Out Without Proper Execution

Jul 11, 2013

the following code doesn't execute properly( After the second entry the program comes out)!!

Code:

#include<stdio.h>
void linkfloat();
int main(){
struct book {
char name;
float price;
int page;
};

[code]....

View 8 Replies View Related

C++ :: Preventing Execution Of A Function

Jun 26, 2013

PHP Code:

class MyClass{};namespace BI{    class BusinessInterop {    
public:        static MyClass* func( {
printf("BusinessInterop");return new MyClass();}    

[Code] .....

I would like to know how to prevent the program print out "Business", I'd like it to call the base class's static function. I have tried to changed MyClass* into void* but it still prints Business :grumpy:.

My challenge is to output "BusinessInterop" without any changes made to the polymorphic structure as designed.

View 7 Replies View Related

C :: Unary Increment Operator Execution

Nov 28, 2013

how the output for the program below comes to 45 and 46 respectively.

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int x=10,y=10;
clrscr();
//printf("%d

[Code] ....

The output obtained for the above program is 45 and 46.

View 4 Replies View Related

C :: No Permanent Storage During Program Execution?

May 22, 2013

Code:

#include <stdio.h>
int sum_array(int * , int );
int main(void)
{
int total = sum_array( (int []) { 1 , 2 , 3 , 4 } , 4 );
}

[code]....

We create an unnamed array "on the fly" that it means array has no permanent storage during the program execution?

View 11 Replies View Related

C++ :: Windows Path - Folder Of Execution

Jan 17, 2014

This question is currently only for windows; but I would like to know about a cross-platform way to perform what I want to do (explained below) -

I have created a little program:

#include <iostream>
int main(int argc, char *argv[]) {
for (int i = 0; i < argc; ++i) {
std::cout << argv[i] << '
';
} }

I have added this program to the windows PATH. I put this program in C:Program FilesProgram

I now navigate to C:DataVariousTexts using CMD.

Then I type in: "program x"

The program will print out "program x" as by default. What I would like to get hold of is the folder in which the program is actually being called. ( I want to somehow get "C:DataVariousTexts" to be read into my program ).

How do I perform such an operation?

View 5 Replies View Related

C# :: Fatal Error During Command Execution

Dec 31, 2014

Why i keep getting the above error. below is my code:

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

[Code] .....

Attached image(s)

View 5 Replies View Related

C# :: How To Repeat Execution Of Code Using Counter

Oct 22, 2014

I have a method that changes a canvas color after set intervals, e.g. start timer, 5 seconds green, 3 seconds red, then stop. This functionality is provided in the interval method. The problem I'm trying to achieve is getting this sequence to repeat for a set number of iterations.

I tried to solve this by setting up a counter after the timer is stopped but the code keeps repeating indefinitely by starting and stopping over and over instead of the max of 6 iterations I had set. In debugging the problem, I watched the value of 'i' and when the 'if' statement is set to false. The 'if' statement gets set to false after 7 iteration as expected but the start(); keeps getting called.

void myTimer_Tick(object sender, EventArgs e) {
//Assign text box string value to a time span variable.
TimeSpan workTm = TimeSpan.ParseExact(wrkString, @"hh : mm : ss : fff", CultureInfo.InvariantCulture);
TimeSpan restTm = TimeSpan.ParseExact(rstString, @"hh : mm : ss : fff", CultureInfo.InvariantCulture);

// update the textblock on the display
// with hh, mm, ss, ms
ms = myStopwatch.ElapsedMilliseconds;

[Code] .....

View 1 Replies View Related

C++ :: Comparing Execution Times Of Summation

Mar 17, 2014

This is the problem:

1+2+3+...+n=(n(n+1))/2

Write a C++ program that compares the execution time of the above summation using two different solutions: one that uses loops, and another that uses the closed form approach. Use large values of n for the comparisons, such as, 10^7, 10^8, 10^9, 10^10, 10^11,10^12, 10^13, and 10^14. Provide a comparison table for the execution time in both solutions.Do not worry about the value of the actual sum. Overflow will occur in the sum value rendering it invalid; however, this is not the primary concern of the program. Execution time is the primary concern.

View 1 Replies View Related

C :: Anomalous Execution Of For Loop And The Function Call

Aug 18, 2014

I have a for loop, and after this loop, I am calling another function that wakes a thread S, and then thread S carries on its execution.

Code:

for (k = 0; k < num_msg; k++) {
if( (c % Messages[k][2] ) == 0 ) {
printf("
%d, act, %d

[Code]....

I am getting an anomalous output. Before all the iterations of for loop could finish, the program enters into the invoke_thread_S() and I can see the remaining iterations of for loop happening after thread S is finished.

What could be the problem here. Can I put a 'sleep' before I enter into invoke_thread_S() function, I tried it with a very small amount (in nano seconds), but that did not solve the problem.

View 8 Replies View Related

C++ :: Control Execution Of Code Block By Entry

Apr 25, 2013

I have a program including several code blocks in the following simplified structure:

int main() {
// block A
if(a > 0) {
}

// block B
if(a > 1) {
} }

Block A and B should be executed separately, according to entry from keyboard. For example, if entry "1", block A will be executed and block B will be ignored; if entry "2" the inverse will happen.

I can control the execution of these two blocks through macro but the code will be separated during compilation. But is there a way to control them without using macro?

View 4 Replies View Related

C/C++ :: How To Increase Size Of Array During Program Execution

Apr 23, 2013

how we will increase the size of an arry during program execution. eg if the size of an array is 40 and during prog exexution we want to increase the size of an arry ,what is the procedure.

View 1 Replies View Related







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