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


ADVERTISEMENT

C++ :: Displaying Commas In Loop?

Oct 6, 2013

If the number 4 is entered, the output should be the following:

1: 1
2: 1, 2
3: 1, 3
4: 1, 2, 4,

My output, however, is different but I know its an error with the comma.f

1: 1, , ,
2: 1, 2, ,
3: 1, , 3,
4: 1, 2, , 4

Here is my code:

#include <iostream>
using namespace std;
int main()
{

[Code].....

View 1 Replies View Related

C++ :: Displaying Correct Output By Using For Loop (with Pointers)

Feb 4, 2014

I wanted to display the correct output by using a for loop at the end of my code, but for some reason it's not working correctly.

#include <iostream>
using namespace std;
int main() {
int* ipArray[3];
for(int i = 0; i < 3; i++) {
ipArray[i] = new int [5];

[Code] .....

What I wanted to do is pretty much match my 1st out put like 0 1 2 3 4 but my 2nd output only outputs 24's and I don't know why

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 :: Function To End A Loop?

Nov 8, 2013

Is there a way to end a loop ?

Code:
while ( menuopt == 1)
{
printf("Lets start
");
printf("12 x 4 = ?
");

[Code] ....

View 2 Replies View Related

C/C++ :: While Loop Function?

Apr 27, 2015

"Write a program to gauge the rate of inflation for the past year. The program asks for the price of an item (such as a hot dog or a 1-carat diamond) both one year ago and today. It estimates the inflation rate as the difference in price divided by the year-ago price. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the rate of inflation. The inflation rate should be a value of type double giving the rate as a percent, for example 5.3 for 5.3 percent.

Your program must use a function to compute the rate of inflation. A program which does not use a function will be awarded a score of zero, even if all tests pass."

So far I've got the code below. It runs, but it outputs zero for the inflation (no matter how values I enter for the prices) and does not stop running when I enter zero.

#include <cstdio>
#include <iostream>
#include<cmath>

[Code].....

View 3 Replies View Related

C++ :: Creating Do-While Loop In Program

Apr 28, 2014

I need starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score.

Here's what I have so far:

Code:
{
//This program calculates a golfers handicap.
#include <iostream>
#include <string>
using namespace std;

[Code] ....

View 1 Replies View Related

C :: Use A Loop To Restart A Program

Feb 21, 2015

I've just started to learn C programming. In following program I need to use a loop, so at the end, it asks the user that if wants to try other numbers or not. If yes program restarts from beginning.

Code:
/*
A program who checks three positive integers to be 3 sides of a triangle and calculates the area and shows the triangle type.
*/

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)

[Code] .....

View 11 Replies View Related

C :: Simple Loop Program?

Feb 27, 2014

3. Write a program that reads a sequence of positive integers and prints out their sum, except that if the same number occurs several times consecutively, ignore all but the first. Assume an input of 0 marks the end of the input. For example, if the input is 3 8 5 5 4 9 1 1 1 1 8 0 then you should print 38 (i.e., ignore one of the 5's and three of the 1's).

View 5 Replies View Related

C :: Make A Program Using While Or For Loop?

Nov 20, 2014

I'm trying to write a program for a lab, I know how easy it is but cant see to crack it.

I need to make a program using while or for loop.

I must have the user type a number, for an input value an output value but then do it again several times but without it going on forever asking again and again.

View 4 Replies View Related

C++ :: How To Make A Loop So Program Never End

Aug 29, 2014

How to make a loop so program never end, it end only by typing "EXIT"

View 1 Replies View Related

C/C++ :: Loop Function Freezes GUI

Jan 9, 2015

I'm trying to loop a function in C++/CLI but it freezes my GUI and i can't do anything anymore when this happens. Here is the part of it;

DWORD Conqq = 0x0053A124;
void ConqqFunction(bool fEnable) {
if(fEnable) {
while(1) {
for( ; ; ) {
WriteMemory(Conqq, 1, 0xD2);

[Code] ....

It freezes after i activate this function with checking the checkbox. How can i resolve this? I don't want the GUI to freeze.

View 6 Replies View Related

C++ :: Program With Do-while Loop To Restart Program And Validation

May 11, 2013

I am having problems at the end of the program with the do-while loop to restart the program and the validation.

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <time.h>
using namespace std;

[code]....

View 3 Replies View Related

C++ :: Program To Enter Limit Of A Loop

Feb 20, 2013

I need a program in c++ that will enter a limit of the loop. using nested for loop with a limit of 3 loops only.

like this !

for (){
for (){
for (){
cout
}
}
}

Sample output:
Enter a number : 3 [enter]

1 2 3
4 5 6
7 8 9

2 3 4
5 6 7
8 9 10

3 4 5
6 7 8
9 10 11

View 2 Replies View Related

C/C++ :: Infinite For Loop - Program Just Closes

Feb 10, 2015

So I learned how to make a basic for loop and I decided to try my best to make an infinite one. Every time I run it, it doesn't say anything and just closes. Visual Studio doesn't say there's anything wrong with my code.

Here's the code

#include <iostream>
#include <conio.h>
using namespace std;
int main () {
int d = 9;
for(int k = 10; k < d; k = k +1) {
cout << "For loop value = " << k << endl;
getch();
} }

View 4 Replies View Related

C/C++ :: How To Loop A Program Back To Beginning

Mar 4, 2014

I was asked by my teacher to create while loop for this, iv have completely for gotten how and all the tutorial that i have found show basic lopping.

#include <iostream>
#include <iomanip>
using namespace std;
void checkAnswers(char[], char[], int, int);
int main(int argc, const char * argv[]) {
int choice = 0;
const int num_question=20;
const int min_correct=15;
char answers[num_question] ={

[Code] ....

View 5 Replies View Related

C++ :: Cab Company Program / Endless Loop?

Jan 14, 2015

I'm trying to get this program to return total taxi cab fair an infinite number of times, however, when I use the while statement after for and try to run the program, it just keeps displaying the first total fair rapidly.

specifications:A cab company needs a program to calculate the cost of a cab ride.

The driver will enter the length of the trip in miles.

The miles entered must be greater than 0.

Create a function to calculate the charge. The function should receive one argument, the length of the trip, and should return the total fare for the ride.

The taxi charges a fixed charge of $2.50, plus an additional charge of $1.85 per mile.

Allow the user to calculate any number of trips.

At the end display the total of all the fares.

here is my code:

#include <iostream>
#include <iomanip>
using namespace std;
//function prototypes
double getLength ();
int main () {

[code]....

View 3 Replies View Related

C++ :: Decipher Program - Nested Loop

Feb 17, 2013

I'm writing a series of basic decipher programs and I have run into an issue where I get the correct answer when I start the loops at the iteration that contains the correct answer.

Code:
// generate key "words" with length of 3
for (int x = 0; x < 26; x++){
for (int y = 0; y < 26; y++){
for (int z = 0; z < 26; z++){

[Code] ....

This is the essence of the loop, I've attached the program in its entirety if necessary. Basically what happens is if I start the loops at x = 17, y = 7, z = 12, then I get the correct decipher shifts but if I start at 0,0,0 whenever it gets to that iteration (12,000 ish) the shifts are off by 2 or 3. "koq" should translate to "the" but im getting "dcz". Is this a simple bug in the or is something moving to fast for something else to keep up?

l3_ws.txt
main.cpp

View 1 Replies View Related

C++ :: Using Break In Void Function That Does Not Contain A Loop

Jan 14, 2015

I need this break in my main function, but I'm not allowed to put it in void since void is not located in a loop. How can I solve this?

Code:
#include <iostream>#include <string>
using namespace std;
void login(string x, string y);
string username;
string password;
string x;
string y;

[Code] ....

View 6 Replies View Related

C :: How To Loop Back To The Beginning Of Function

Oct 11, 2014

I am writing another program and I cannot find for the life of me how to loop the program back to the start of a function.

Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int choice;
char band1, band2, band3, band4;
printf ("This program calculates the resistor value based on the colours of the wire.
(enter the integer near the command)
");
printf ("What would you like to do?

[Code].....

This is my current iteration of the program. Obviously, I haven't finished writing the case 1 of the first switch, but for the other ones. I thought that return main would cause the program to loop back to the beginning after executing the case, but I see that it is not the case (pun not intended). Anyways, what would I have to insert to cause the program to loop again (other than for case 3)? And another question, why is it that in scanf in the first case, the program only accepts two characters before finishing?

View 4 Replies View Related

C :: Converting For Loop To Recursive Function

Jun 10, 2013

I am working on a problem that requires a nest for loop to be converted to a recursive function. I am going to provide just the code instead of the entire program.

Code:

for (R1=1; R1 <+3, R1++){ //for loop
printf (something);
}
// the recursive function
void loopR1 (int R1, int max){
if (R1 <= max){
printf (something);

[Code]...

when calling the recursive function in main i am using the following statement...

loop r1(1,3)

View 4 Replies View Related

C :: Loop Function That Scans For A Letter

Apr 29, 2013

How can loop this function so it keeps asking the user till they enter a correct letter that can be found in the unscrambled array?

Code:
char LetterGuessed(char unscrambled[]) {
char c;

printf("+-----------------------------+
");
printf("| Please guess a letter: |

[Code] .....

View 1 Replies View Related

C++ :: How To Return Value Of A By Calling Function Loop

May 29, 2014

Suppose I have the following function containing while loop:

#include <iostream>
using namespace std;
int Loop () {

[Code]....

here in above code I want to return value of 'a' by calling function 'Loop'. Is there any way to do this??

for above code output should be:

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19

View 8 Replies View Related

C++ :: Convert A Recursive Function To A Loop?

Dec 13, 2014

I am trying to convert a recursive function to a loop. However, it is not working.

//recursive function
int function(int x){
if (x % 3 == 0){

[Code]....

View 1 Replies View Related

C++ :: Function Returns Values After Loop Done

May 15, 2013

I am writing a program with a function that includes a long loop. I need this function to return a value when each loop is done, to send this value to output, in order to follow the progression. But I don't know how to do it in easy way. The function is like follow:

int goC(){
... // some local value definition
for(int i = 0; i < 1000; i++){
... // a lot of calculations done here
return i; // -> return the value after each loop is done
}
}

Here it only returns one value, i = 0. Clearly it's wrong.

View 10 Replies View Related







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