C++ :: While Loop Stops Output
Jun 19, 2014
As I was testing it, the program suddenly stopped giving an output. Here is the code:
#include <iostream>
using namespace std;
int main() {
cout << "Ten people ate breakfast with you this morning. Each of them " <<
"had pancakes.
Please enter how many pancakes each of the ten people " <<
"ate.
" << endl;
[Code] ...
The while loop after int glutton does not work and seems to stop the program. I replaced the "glutton" in the cout with "testing testing" and it still did not work. However, when I commented out the loop, it appeared. Finally, it can't be what's inside the loop, because I commented that out too, and it still didn't work.
View 2 Replies
ADVERTISEMENT
Jul 21, 2013
is it possible to output like this using only one loop? if yes, how?
target output Code: ABCDE
EDCBA here is my code but using one loop im not getting my target output Code: #include <stdio.h>
main()
{
int x, y;
for(x='a', y='e'; x<='e'; x++, y--)
{
printf("%c
%c", x, y);
}
getch();
}
View 6 Replies
View Related
Nov 6, 2013
trying to output my struct to a for loop. I understand how to output the struct but not into a for loop.
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
struct Date {
int day;
int month;
int year;
[code]....
View 16 Replies
View Related
Dec 6, 2013
the program is of an address book. the syntax is all fine, and the initial menu of options does show up. but once you punch in the cin, the program just stops.
View 9 Replies
View Related
Nov 14, 2014
Something is wrong with option 1. For some reason it adds 1, 2, 3, 4 ... 5 onto the output and I can't think why. Here is a screenshot.
Also how can I make the output a little neater? I tried to use but it just looks horrible.
I had linked the source code! Why is there no edit button?!
#include<iostream>
using namespace std;
int main(){
int option;
cout << "Welcome to my program. Please select a following option.
[Code] .....
View 3 Replies
View Related
Sep 13, 2013
I am trying to enter data to a structure some 8 times, but not able to do so. Here is my code.
Code: #include<stdio.h>
struct _Timer {
unsigned int HH;
unsigned int MM;
}Time[8];
[code]...
But when I enter any data and press enter , the .exe file stops working and not able to enter data.
View 4 Replies
View Related
Nov 11, 2014
I am currently working on a c++ project that will input students and process their grades. I encountered a problem and my code stops executing after the getScores function. Im not sure what the problem is, but im guessing its something within the function and the loops.
//Name: getScores
//Description: Will get scores for student
//Parameters: None
//Return: testScore
double getScores()
[code]....
View 6 Replies
View Related
Feb 9, 2015
i wrote a little program with fseek. It works good till it reaches the first fseek(). Then it crashes and stops responding.My code:
ifstream inp("myfile.txt");
if(!inp.is_open()) return false;
inp.close();
FILE *f;
fopen("myfile.txt","rb");
[code].....
View 2 Replies
View Related
Oct 3, 2013
Just using Find in my source code to look for variables or whatever, works once or twice then just stops - Doesn't find anything even if it's there. If I restart VS it works again, but not for long.
View 1 Replies
View Related
Jan 23, 2014
so i got this piece of code today having some slight errors with it, how its actually done as i want to know where i have gone wrong here is the code .. Using a for loop to input and output array values
*/
#include <stdio.h>
int main(void) {
/* Declare an array of integers */
int Grades[5];
int nCount;
/* Populate the array */
for(nCount = 0; nCount < 5; nCount++)
[Code]...
View 3 Replies
View Related
Feb 28, 2013
What does the following nested loop output ?
count = 1;
while (count <= 11) {
innerCount = 1
while innerCount <= (12 - count) / 2) {
cout << " ";
innerCount++;
} innerCount = 1;
while (innerCount <= count) {
cout << "@";
innerCount++;
} cout << endl;
count++;
}
View 9 Replies
View Related
Jul 30, 2014
[URL] when I try to write my output to a file. I am building a life insurance premium calculator with c++. What my calculator does is read in a text file called "policies.txt" containing a number of different policies. For example:
Pol1 M N 20 100000 1 .04 99
Pol2 F S 30 100000 1 .05 99
Pol3 M S 72 750000 1 .03 99
Pol4 F N 45 1000000 1 .05 99
And using this, it creates a single premium. Once the calculator calculates the premium of each policy, I want it to write out the premium amount of each policy to a textfile called "output.txt". The problem is that when I check my "output.txt" file, only the premium for the last policy shows up. It only reads:
Premium for Pol4 is 220384
When I want it to read:
Premium for Pol1 is 14101.6
Premium for Pol2 is 14221.2
Premium for Pol3 is 582391
Premium for Pol4 is 220384
How come only the last policy is showing up? and is there any way to make all four policies appear in my output text file? Here is my code:
double ratesmn[86] = {
#include "MaleNonSmoker.txt"
- 1
};
[Code]....
View 2 Replies
View Related
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
Mar 1, 2015
So I'm having trouble with my code. Got it to work, but having issues in terms of indenting my increment. For this example, I will use * as whitespaces.
Expected output:
0
*1
**2
***3
Your output:
0
*1
**2
***3
*****
The expected output has no extra whitespaces, but mine does. What am I doing wrong?
#include <iostream>
using namespace std;
int main() {
int userNum = 0;
int i = 0;
int j = 0;
for(i =0; i <= userNum; i++){
[Code] ....
View 5 Replies
View Related
Feb 21, 2013
How to fix this when i run the program and enter my name then output my name in vertical position using the for loop and press enter the program do not stop
#include<stdio.h>
#include<conio.h>
#include<dos.h>
main() {
char name,n;
clrscr();
printf("Enter Your Name:");
scanf("%c",&name);
[Code] ....
View 3 Replies
View Related
Nov 21, 2014
My loop is outputting data incorrectly. I have inbound web data that come in sets of 7. I am trying to in insert the 7 records into a vector and then display the vector content followed by a new line.
Code:
char buff[BUFSIZ];
FILE *fp = stdout;
char * cstr = buff;
vector<std::string> vrecords;
while(std::fgets(buff, sizeof buff, fp) != NULL){
for(int i = 0; i < 6; ++i){
[Code] ....
expected output:
Found buy!
198397652
2014-11-14 15:10:10
Buy
0.00517290
0.00100000
0.00100000
0.00000517
[Code] ....
View 14 Replies
View Related
Feb 22, 2013
I'm having troubles with this program I made. Put it simply, it's a basic program using Queues. Whenever I try to input a value, my compiler(Dev C) suddenly stops working. The .exe file crashes and I've no way on how I can execute my program.
Code :
#include<iostream>
using namespace std;
int *queue;
int rear, front, queueSize;
void enqueue();
void dequeue();
void display();
[Code] ....
View 1 Replies
View Related
Sep 15, 2012
I'm making an apllication which needs to play .wav file when user type something inside QTextEdit. I made some code but after minute or less the sound stops, so I made silly workarround. After 30 clicks I invoke sound->stop(); and then the loop start again, that works, but it's not good, can you give better solution. Here is my code:
Code:
int count = 0;
bool MainWindow::eventFilter(QObject *o, QEvent *e){
if(e->type() == QEvent::KeyPress)
{
tipka->play();
tipka->seek(0);
[Code]...
View 1 Replies
View Related
Aug 31, 2013
I am trying to code a partition quicksort but the problem here is at the output is in an infinite loop:
The input : 4 3 5 7 2
The expected output : 2 3 4 5 7
But my output is infinite :
2 3 4 5 7
2 3 4 5 7
2 3 4 5 7
.
.
and so on
[Code:
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
/* Head ends here */
void partition(vector <int> ar) {
[Code] .....
View 5 Replies
View Related
Jun 12, 2014
Basically I'm supposed to use a while loop to generate a random number and use a switch statement to output the appropriate information. I feel like I'm missing a few things that are very simple.
The errors are:
warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
warning C4700: uninitialized local variable 'randomNumber' used
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main(){
int i = 0;
unsigned int randomNumber;
[Code] .....
View 2 Replies
View Related
Jan 24, 2014
I have this code that im stuck on what i need to do is Extend the code such that when it starts the user is asked to input values to specify each of the three ranges before moving on to accept and tally the main values how do i do that Using a for loop to input and output array values Also calculate the average
*/
#include <stdio.h>
int main(void)
{
/* Declare an array of integers */
int Grades[5];
int nCount;
int nTotal = 0; /* Declare and initialise the value */
float fAverage;
[Code]...
View 1 Replies
View Related
Aug 18, 2014
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.Ports;
[Code] ....
How to pick date / time when serial port starts reading , and also when reading stops ?
View 2 Replies
View Related
Mar 9, 2015
I need to write a program to input 6 temperatures in degrees Fahrenheit and output it in degrees Celsius. I used a for loop but it keeps giving me 0 as the output whenever I enter a temperature...
Code:
#include <stdio.h>
#include <math.h>
int main() {
double farenheit,celsius;
for(int i=0; i<6; i++) {
printf("Enter temperature in degrees farenheit: ");
scanf("%lf",&farenheit);
celsius = (5/9)*(farenheit-32);
printf("Temperature in degrees celsius: %lf ",celsius);
} }
View 5 Replies
View Related
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
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
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