C++ :: Don't Give Correct Location Of Max / Min Number In Array
Nov 8, 2013
All my code is good, except the functions: findMacLoc and findMinLoc .They don't give me the correct array location of the max/min number in the array.I know is something simple I need to tweak in those two functions.
#include <iostream>
#include <time.h>
using namespace std;
void printArray(int a [], int & size)
{
int i;
for (i = 0; i < size; i++)
cout << a[i] << " ";
[code].....
View 2 Replies
ADVERTISEMENT
Oct 9, 2013
I was told to use a round function to round a number to give an integer number that is closer to the real value. (for example if the number is 114.67 I need to print an int value of 115 instead of 114)
I am not exactly sure how a round function works, but I am told to include math.h library. What I try doesn't seem to work.
View 1 Replies
View Related
Nov 18, 2014
I'm saving the images in folder by using:
webClient.DownloadFile(href, sourcepath);
I don't want to give name as Current date and time..shown in given below code
string sub = @"Gadhada";
DirectoryInfo subFolder = dir1.CreateSubdirectory(sub);
Imagename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
[Code].....
I want to save my imagename as 1.jpg, 2.jpg, 3.jpg.
View 1 Replies
View Related
Dec 30, 2014
i have only recently got into programming. i have this homework assignment that is frying my brains, the program needs to take a number from the user and give the 'reduced' sum. for example: if the user enters 888 then the sum should be: 6. it takes the number and adds its digits im just looking for a direction to where my problem is
#include "iostream.h"
int reduction (int number) {
return number/10+number%10;
}
int main() {
int number,loopcount;
cout<< "please enter a number"<<endl;
cin>>number;
[Code]...
View 2 Replies
View Related
Mar 19, 2014
I have two unassigned variables A,B . My program goes as follows
#include <iostream>
#include <string>
#include <cmath>
#include <stdlib.h>
using namespace std;
bool die (const string & msg);
[Code] ....
This a program that makes a calculator in which this is a small portion of it, all the exponent numbers work exceptfor anything ending in 5.
Examples go as follow 2^3=8, 3^2=9, 5^2=24
I want to why this happens, is it because they are unassigned variables?
View 1 Replies
View Related
Jan 11, 2014
I have created an error message if the user inputs the wrong selection number
if (choices < 1 || choices > 5)
{
cout << "
Please Enter a number between 1-5
";
}
How would i create a error message if the user inputs letters/words instead of a number.
View 5 Replies
View Related
Nov 4, 2013
I am currently working on an assignment.
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
char letter;
int count = 0;
double ppl = 0;
double finalCost = ppl * (count - 1);
[Code] ....
I am trying to create a word counter program that asks for the price per letter and then asks for the sentence they are writing. The app should then calculate the number of letters and give the total cost similar to:
You have 40 letters at $3.45 per letter, and your total is $138.00.
Everything compiles fine but when I run it the inputs don't work and it outputs:
You have -1 per letter, and your total cost is $-0.
View 2 Replies
View Related
May 10, 2014
I am a beginner at C++, the output is pretty self explanatory. I'm trying to make a number sorting program with other features, but the numbers are all wrong.
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
[Code] .....
Input.DAT
Code:
376 389 450 735 600 576 612 700 450 628 778 389 667 500 475 550 687 791 829 344
549 476 400 587 535 657 789 583 340 764 422 826 566 436 565 834 533 423 837 701
847 521 746 356 582 465 493 593 425 421
I can't for the life of me figure out why the numbers are all messed up.
View 5 Replies
View Related
Apr 9, 2013
I am having one issue with my project. We are making a game of Nim code.I'm 99% done with it, i worked hard on it and i feel like i did a good job, however my project is not displaying the matches i want. For example, it display's the inital number of them 23. But once the first player subtracts a number, it doesn't display matches for player 2, just the number of matches remaining. Then as i keep running the program the same thing happens. This is what it's supposed to
output:
"Input/Output sample
WELCOME TO NIM
------- -- ---
Enter the starting player's name (no spaces)-->John
Enter the second player's name (no spaces)-->Mary
There are 23 matches.
ooooooooooooooooooooooo
|||||||||||||||||||||||
Player John please enter the number of matches to remove-->2
There are 21 matches.
ooooooooooooooooooooo
|||||||||||||||||||||
Player Mary please enter the number of matches to remove-->3
There are 18 matches.
oooooooooooooooooo
||||||||||||||||||
Player John please enter the number of matches to remove-->1 "
This is entire code.
#include <iostream>
#include <string>
using namespace std;
int main() {
// Holds variables.
[Code] ....
I will attach my code as well.ProjectNim.cpp
View 7 Replies
View Related
Aug 4, 2014
I have a contiguous sequence of section headers in a file (all the data in the file is stored in void * data), where each section header is the same size and has the same fields in the same order. So it's laid out like an array.
I have to:
- Use an offset value and the number of section headers variables to identify the location and length of the section header table (these are hdr.offset and hdr.length respectively).
- The offset value shows the distance between the start of the file and the start of the first section header (so I need a pointer to the start of the first section header)
- Apply a typecast to location of the section header table to process it as an array of section headers.
Here is what I have done, but I am getting a segmentation fault. What am I doing wrong? How do I fix this?
typedef struct {
unsigned int name;
unsigned int type;
} SectionHeader;
[Code] ....
View 1 Replies
View Related
Apr 1, 2013
I have been trying to make a function that compares all the values of the array and if they are all equal will return a value to print true. The problem I am having is that regardless of what values I enter the function is always returning true. Any way to tell the program o check all the values in one command instead I put them each,
Code:
#include<stdio.h>
#include<stdlib.h>
int compare(int arrayA[], int arrayB[]);
[Code]....
View 2 Replies
View Related
Apr 25, 2013
This for loop replaces the stars ******** in an array that contains a word to be guessed with the correct letter (c) that the user inputs if the word contains that letter.
Problem: After every guess the same hidden string of stars ******* is displayed instead of ex: ***W**** (assuming W was entered by the user)
How can I update the old ******** string in the Stars array with the new string that includes the correct letters chosen, so after every correct guess at a letter in the word a new string is displayed including the correct letters chosen?
I'm pretty sure I have to use strcpy but not sure how to implement it using a loop.
Code:
for(i = 0; i < strlen(unscrambledWord); i++) {
if(unscrambledWord [i] == c) {
Stars[i] = c;
} }
View 1 Replies
View Related
Aug 26, 2013
If i have character string 'char name[30]' how to give validation for the name entered by user?
View 4 Replies
View Related
Jul 14, 2014
I am designing a form ..in wich i used 3 buttons...from these 3 butons ,i wanna give backcolor to button1 . How to give it a backcolor?
View 1 Replies
View Related
May 2, 2014
#define PROJECT_ID ram
#define QUOTES(FILENAME) #FILENAME
#define DATA_VAR_FILENAME(PROJECT_ID) QUOTES(../##PROJECT_ID##_data_var.h)
#define DATA_VAR_FILE(PROJECT_ID) DATA_VAR_FILENAME(PROJECT_ID)
#define CUST_DATA_VAR_FILENAME DATA_VAR_FILE(PROJECT_ID)
When I tried to include CUST_DATA_VAR_FILENAME like below
#include CUST_DATA_VAR_FILENAME
Will get below error
error: pasting "/" and "ram" does not give a valid preprocessing token
View 1 Replies
View Related
Oct 11, 2012
Is there any methods to add scroll bar for group box
My code scenerio is: I have many groupbox in form, all group box will be appears in same place and also height and width is fixed. I'm doing group box visible true/false according to condition.
So some groupbox ecxeeds the width and heighto so I want to put this all in scroll Bar
View 2 Replies
View Related
Apr 15, 2012
I'm trying to build a basic shell for Unix. This is the code I use to create a new process:
Code:
pid = fork();
if (pid == 0) {
setpgrp();
complexCommand(argv, isComplex);
[code] .....
Where complexCommand is a function that handles the command (uses execvp after generating the correct string out of argv). My problem is that after if while in the shell I use a program that needs to print to the screen and handle input, it doesn't work as expected. To test this, I built this small program:
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
int x1, x2;
[code] ....
And when I use the shell I built to run it, the output is only "Enter 2 numbers" for one time. It doesn't print the result, or anything else. Is there anything I need to do in the parent process (my shell in this case) to give the child the output?
View 2 Replies
View Related
Apr 11, 2013
how to give a database connection to a c++ code i am using turbo c++ as an editor and if i have oracle 11g client, odbc as a driver , what else i require and how to link these things in a code.
View 1 Replies
View Related
Feb 5, 2014
I'm creating a bank system.
So I know to make a deposit to the balance, which add ups what is the balance to i have add.
When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.
Code:
double deposit(double balance) {
double addSum = 0;
system("CLS");
cout<< "Welcome to deposit."<<endl;
cout<<"Enter a sum you wish to add to your account:";
[code]...
When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0 When i make another withdraw from example -150, it will be -150.Which shows correct.
But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.
Code:
double withdraw(double balance) {
double takeSum = 0;
system("CLS");
cout<< "Welcome to withdraw."<<endl;
cout<<"Enter a sum you wish to take away from your account:";
[code]...
View 2 Replies
View Related
Jan 26, 2013
You are given 3 integers x,y,z. you must find all groups of x integers until y, that when added give a sum of z.
View 2 Replies
View Related
May 9, 2014
I am trying to give fraction object in s string via template.
struct Fr // simple Fraction {
int num;
int denom;
Fr(int i,int j) {
[Code] ....
View 10 Replies
View Related
Aug 21, 2014
I am trying to read this xml file. This readFile function does not give me right values. Only to use cstring..no pointers or other libs such as xml libs
void readFile(char file[], ifstream& read){
char line[chr_len];
read.open(file, ios::in);
if(read.fail())
cout<<"Sorry could not read";
[Code] ....
Also how can i only read the values..not the tags?
View 8 Replies
View Related
Apr 4, 2013
I need to write a program that will give me multiple calculation results.
#include <iostream>
using namespace std;
int main () {
int x = 8;
int y = 7;
[Code] ....
It only calculates the last two numbers: 1 and 0, so therefor it gives me 1.
But i need to calculate x and y each time they are smaller(incremented) by one digit.
Please note that the int calculation formula needs to stay.
View 2 Replies
View Related
Apr 23, 2014
I cant get with part of it is wrong, i want to sum every row, too.
// Color Number.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<conio.h>
#include<iostream>
[Code].....
View 1 Replies
View Related
Jun 16, 2012
can we give the restriction to method for a particular class
View 1 Replies
View Related
Nov 2, 2013
Code:
#include<stdio.h>
void main
{
int i;
int marks[10];
}
[code]....
how to give error and ask user to re enter if user enter other then a number?
View 6 Replies
View Related