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


ADVERTISEMENT

C++ :: Creating A Loop To Allow User To Choose To Return To Beginning Of Program Or Quit

Apr 6, 2014

I am currently having problems creating a loop that will allow my user to choose to return to the beginning of the program or quit.

#include <iostream>
using namespace std;
int main() {
int j;
do {float a;
cout << "+----Welcome to Basic Operations----+
| Select Your Operation |

[Code] .....

I have not yet finished designing the interface for a couple of the operations, but right now i am hung up on trying to return to the beginning. I believe it is because the j was defined inside do and isn't carried out of the do statement for while.

View 13 Replies View Related

C++ :: Creating A Loop To Calculate Formula?

Mar 21, 2014

I am trying to create a code and cannot get the following part to work :

for (int n = 0; n = timesteps; n++)
{
n = n + 0.1 ;
cout<< "timesteps"<< n << endl ; //print time step value =0.1
for (int j = 0; j < nodesinx; j++)
{
T[j][n+1] = T[j][n] + 0.16 * (T[j][n] - 1[n] - 2[T[j][n] + T[j] + 1[n] ; //equation
n= n + 0.1 ;
cout<< "temperature" << T[j][n+1] << endl;
T[j][n+1] = 0.0 ;
}
}

View 1 Replies View Related

C/C++ :: Creating A Binary Search Loop?

Oct 13, 2014

I am creating a binary search program that lets the user input up to 10 integers and then the program displays the array and sorts it. When the user is prompted to select an integer, if the integer is in the array, the program responds with the array subscript part. I can get the loop to work once and maximum twice, but then it wont search for the array or say value not found even though the number in in the array. I tried making the values NULL but that only lets me go through it one more time.

Here is my code:

#include <iostream>
using namespace std;
//Functions
void printArray(int);
void selection(int);
int binarySearch(int,int,int);

[code]....

View 6 Replies View Related

C++ :: Creating Multidimensional Array In Infinite Loop?

Aug 13, 2014

From the example given below, I would like to Generate a matrix who stores a generated array for each iteration. I have an understanding of inputting single elements to a matrix but how can I input an array to a matrix. let's say I would like to input and array of 4 elements that should be stored as a single row of the generated matrix and do this for an infinite while{true} loop.

#include <iostream>
#include <unistd.h>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

void printArray(int arr[], int size) {

[Code] ....

View 7 Replies View Related

C# :: Creating Multiple Labels In Foreach Loop

Apr 29, 2015

I am attempting to create multiple labels in a for each loop for each tag text (using htmlagility pack). My current code only creates one and doesn't change the first value (Which is AAE). I am using the labels to later input all the label.text into a database after the initial loop has finished (not shown).

foreach (var tag in tdTags) {
MessageBox.Show(tag.InnerHtml);
Label label = new Label();
label.Name = "contentName" + tag.InnerHtml;
label.Text = tag.InnerHtml;

[Code] ....

View 3 Replies View Related

C/C++ :: Combing While Loop Read With Creating A Pipe

Oct 30, 2014

I have this if block that is supposed to be creating a pipe then forking and I would like to combine the while loop below it with it. How would I do that?

p = pipe(pipe1);
if (p < 0) {
printf("pipe error");
exit(0);
} else {
printf("successful pipe1 = %d",p);

[Code].....

I have trying to read this documentation but don't understand it. [URL] ....

View 1 Replies View Related

C :: Creating Simple Address Book Struct - For Loop?

May 11, 2014

My address book will be simple, and the thing's that I'm expecting to use in it are :

Pointers, Linked Lists
Malloc
Structs
Typedefs
Makefile, header file
Putting functions into different program files

I have started the program trying to create a struct, and getting it working with a couple of entries before going onto user input and splitting it up.

Code:

#include <stdio.h>
#include <stdlib.h>
int main(void) {
// Struct type address book. Just a name, a number and a pointer

[Code] .....

I'm a bit lost at this point... My knee jerk thought is to create a for loop, and cycle through the list.

I'm not sure how this would apply to this though? Without using the familiar type of print loop such as :

Code:
for (i = 0; ;i++) {
printf("%i
", array[i];
}

I'm thinking that I need to create a temporary struct that can be used to assign the value of the next struct in the list, and then somehow print from that....

I'll try and write the logic out :

while temp != NULL (The last node value is assigned NULL to show us where the end of the list is)

create a temporary pointer that can be used to keep track of where we are in the list.

print out the current entry name and number

then assign the temp pointer value to the * next of the current struct. So if we are in entry1 the *next should be the address of entry 2.

Print out entry 2 name and number, assign entry 2 next to the temp value.

View 1 Replies View Related

Visual C++ :: Creating Loop To Call In Entries From Text File Named Set

Jul 14, 2013

I am trying to create a loop to call in the entries from the text file named Set. The entries of Set.txtare :

1 2 3
2 4 5
and so on .. (64 such combinations)[/CODE]

It basically means the first combination for testing is 1 2 3 and next has to be 2 4 5 and so i have 64 such entries defined in set

My test files are located in D://data// and are named tst_data1 to tst_data64.

I created a loop for test set but its incorrect

Code:
// loop for test samples
char basefilename[] = "D://data//";
char , testFilen[160], numiChar[10];

for (int i=1; i<=64; i++) {
strcpy(basefilenme, "D://data//");
strcat(testfilename, Set[]);

[Code] .....

How can i call the Set .txt and how to define it.

View 1 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 :: Creating Border Around Program

Mar 6, 2015

I am trying to create a border around my program. It looks like this: . I had to read a file in, which is in the attachment and produce the desired output in the image. I have produced the desired output, but without the border.

Here is my code thus far:

insert Code:
#include<stdio.h>
#include<Windows.h>

#define HEIGHT 21
#define WIDTH 78

int map[HEIGHT][WIDTH];
int i = 0, j = 0;

[Code] ....

View 2 Replies View Related

Visual C++ :: Creating DLL From Program

Jan 15, 2013

I wanna create a DLL from my C++ program. My output of my C++ program is a text file called Centre_Cartouche.txt My output is two text files called brd.txt and sym.txt

At the beginning my program was just a main which contains all development (Main.cpp). Now I created function (in _Cartouche.h and _Cartouche.cpp).

My debugger tell me that the simulation works. But my file Centre_Cartouche.txt is not create.

_Cartouche.cpp_Cartou.hbrd.txtsym.txt

View 1 Replies View Related

C++ :: Creating Menu Program Using Only If And While For En Do Loops

Mar 13, 2014

I just started learning the basics of programming. While encountering one of the practice problems in the book by Alex Allain I got a little confused. The question is as follows:

Write a menu program that lets the user select from a list of options, and if the input is not one of the options, reprint the list.

The author assumes you can answer this question only using if statements and/or loops (while, for and do).

This is the code I've written thus far:

Code: #include <iostream>
using namespace std;
int main()
{
int option;
char reset;

[Code] ....

For some reason, the nested while loop keeps repeating even when you input a valid option (1, 2 or 3). I can't seem to figure out why this happens.

View 4 Replies View Related

C# :: Creating Encryption Program Like TrueCrypt?

Feb 8, 2014

Is it possible to encrypt a folder and put it in a file container. Would I need to store the header key and other stuff my self or do the encryption methods take care of it? I am just getting into file input/output. I am just looking to make a simple console based one.

View 5 Replies View Related

C++ :: Creating A Program That Encodes And Decodes A Message?

Sep 10, 2014

I am starting this project on how to encode and decode messages that are inputted, how to start this?

View 4 Replies View Related

C++ :: Creating Space Simulator Program For University

Aug 5, 2014

I'm creating a space simulator program for uni and I've got 3 errors that I just can't seem to fix.

View 10 Replies View Related

C++ :: Creating Ability To Read Pages Into Program

Feb 17, 2014

I am working on writing a game that progresses from one "page" to the next. However, with the knowledge and experience I have right now I am only able to hardcode the "Pages" into the source code. I would like to learn how to put the pages into another file "default.pages" and have the program read the file and input the information into itself after I have compiled it. Then, if I change the pages file I simply have to restart the program instead of recompiling all of it. Someone said I should use XML and input it into an object and use that object, but I'm not sure how to do that yet.

I have 3 files right now:

main.cpp, pages.cpp, and pages.h.
//MAIN//

#include <iostream>
#include <string>
#include <fstream>
#include "pages.h"
using namespace std;
const Page gamePages[] = {};

[Code] ....

View 9 Replies View Related

Visual C++ :: Creating DLL That Will Be Used As Plugin In External Program Using MFC

Jan 30, 2013

This is the problem in detail:

I have a VC++ project to create a DLL that will be used as a Plug-in in an external programm. This DLL uses some MFC functions. The initial configuration of the project was:

-Use of MFC: Use MFC in a Static Library

-Common Language Runtime support: No Common Language Runtime support

-Runtime Library: Multi-threaded Debug (/MTd)

This configuration worked fine, there were no compilation errors and the resulting DLL worked correctly.

The problem came when it was necessary to add to the DLL some functions of .NET, using the namespace System and similar. To do that, I had to change the Common Language Runtime support, to Common Language Runtime Support (/clr). Then, when I tried to compile, I got this message:

'/MTd' and '/clr' command-line options are incompatible

So I changed the Runtime Library to Multi-threaded Debug DLL (/MDd). Then I got this error message:

Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version

So I also changed the Use of MFC to Use MFC in a Shared DLL.

After this, the compilation was correct. Then logically the size of the generated DLL is smaller, but this new DLL does not work correctly, the external program in which this DLL is used crashes.

I don't know what to do to fix the problem. Maybe I need to add some other DLLs or files to the directory where the DLL is located, where the external program uses it. But I would prefer to include a single DLL file, but this seems to be incompatible with the use of .NET functionality.

View 11 Replies View Related

C++ :: Creating A Random Number Generator Program?

Aug 9, 2012

I'm trying to create a program that creates random numbers. I looked through some examples and this is what I came up with. The time identifier seems to be undefined yet I see no reason it is undefined.

Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
//Re-seed the random-number generator
time_t now;

[code]...

here's my error code..

1>------ Build started: Project: bake, Configuration: Debug Win32 ------
1> bake.cpp
1>c:usersjonbecherdocumentsvisual studio 2012projectsakeakeake.cpp(8): error C3861: 'time': identifier not found
1>c:usersjonbecherdocumentsvisual studio 2012projectsakeakeake.cpp(9): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 2 Replies View Related

C :: Creating Program That Can Pick Words In A String Or Array

Apr 24, 2013

Creating a C program that can pick words in a string or array and save it in different location, later combine everything in one string or array. It will be using simple programming C code. For example (arrays, pointer) but not interrupts or other string functions.

In a sentence like this:
Size= 70
$--GSV,x,x,x,x,x,x,x,...*hh $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,b,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh $--GLC,xxxx,x.x,a,x.x,a,x.x,a.x,x,a,x.x,a,x.x,a*hh $--GSA,a,a,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x.x,x.x,x.x*hh

The program must capture the $--GGA string then extract from this string:

1) hhmmss.ss
2) IIII.II
3) a (if a = to N or S replace N or S with + or - respectively )
4) yyyyy.yy 5) b (if b = to E or W replace E or W with + or - respectively )

Save them in an array and display as well. After all the saving, the program should combine them to one string. That the final output.

View 7 Replies View Related

C :: Creating Simple Calculator By Splitting The Program In 3 Files

Feb 21, 2014

I am new to C programming, I have been given an assignment to create a simple calculator by splitting the program in 3 files. It should have 2 .c files and 1 .h... I went through the internet extensively and could only come up with this.

main.c:

Code:

//Calculator main.c
#include <stdio.h>
#include <conio.h>
#include "Functions.h"
int main() {
float x = 0, y = 0;
int operation;

[Code]...

Functions.c

Code:

#include "Functions.h"
extern float x, y;
float addition (float a, float b) {
return a + b;

[Code]...

Functions.h

Code:

#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
float Sum(float a, float b);
float difference (float a, float b);
float remainder (float a, float b);
float product (float a, float b);
#endif

When I do a 'cl main.c' on the Developer Command window for VS2013, i get an error that reads :

main.obj
main.obj : error LNK2019: unresolved external symbol _difference referenced in function _main
main.obj : error LNK2019: unresolved external symbol _product referenced in function _main
main.obj : error LNK2019: unresolved external symbol _addition referenced in function _main
main.exe : fatal error LNK1120: 3 unresolved externals

View 5 Replies View Related

C++ :: Creating Infix To Postfix Program Through Inherited Class

Apr 25, 2014

I have the following problem on my C++ Program and I am not sure why it is not working. I am creating a infix to postfix program through an inherited class which I am not sure it is working.

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

int in_stack_Priority(char a){
if(a == '*' || a == '/')
return 2;

[Code] .....

View 3 Replies View Related

C++ :: Creating Program With Parameters To Convert Pounds To Euros

Jan 22, 2015

m creating a program with parameters to convert pounds to euros.

I keep getting this errorc2447: '{' missing function header for the line 'void showPriceInEuros' ....

#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <iomanip> //for endl
#include <Windows.h>
using namespace std;
void processAPrice();
int getPriceInPounds();
int convertPriceIntoEuros(int pounds);

[Code] ....

View 1 Replies View Related

C++ :: How To Impose A Boundary To Stop Program Creating Coordinates

Mar 21, 2013

I am writing a program which creates a set of coordinates that when plotted will reveal a syastro crescent moon character. If you imagine plotting a crescent moon as two circles with different radius, where the overlap will create the shape. The problem I am having is how to just plot where they overlap ( ie the crescent moon part) and no the rest of the circles. How can I impose a boundary to stop the program creating coordinates I dont want. My first attempt is an if else loop.

View 1 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++ :: Creating Binary Tree Program - Allow User To Input Data Types

Apr 23, 2013

In class we were asked to create a C++ BTree program that would allow a user to input the following data types and then store said data in a .txt file:

0. ID 8 bytes

1. First name 30 char

2. Last Name 30 char

3. Street Address one 30 char

4. Street Adress two 30 char

5. City 30 char

6. State 20 char

7. Zip 10 char

8. Country 30 char

(I'm not particularly asking for full code, pseudo code would also be great). I had a great deal of my work done, unfortunately, the computer I was working on crashed, corrupting my files.

View 4 Replies View Related







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