C++ :: Create Single Integer Number From Four Integers
Mar 1, 2014
Write a program that reads four integers from a file ‘input.txt’.
The program will then create a single integer number from the four integers. The output of the program will be the single number and single number + 600.
#include <iostream>
using namespace std;
int main () {
int number , a;
cout<<"enter en integer number";
cin>>number;
cout<<"add 600 to the number"
cin>>a=number+600;
return 0;
}
View 5 Replies
ADVERTISEMENT
Jun 20, 2013
I must create a function with a integer number as parameterThis function use the parameter for a loop...example
n = 1
output
1
2
3
n = 2
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3
View 1 Replies
View Related
Mar 10, 2015
parsing integers and characters in same line.
I trying to parse g8,7.
{
token = strtok(NULL, ",");
token2 = strtok(NULL, "g");
}
I am trying to make 8 an integer so that i get two integers 8 and 7.
I already know how to get 7, but every time i do it i get (0,7) instead of (8,7).
View 8 Replies
View Related
Oct 26, 2013
I have a struct called Array and I'm to create a function to create a dynamic array that's fill with randomly generated integers from 0 to 50 (inclusive) and a function to destroy the array for freeing its memory. Below the code that I have written so far.
Code:
* Struct */
typedef struct {int *pArray; //the dynamic array
int length; //the size of the dynamic array}Array;
/* Function to create a dynamic array */
Array *initializeArray (int length) {int i;
}
[code]....
View 7 Replies
View Related
Mar 22, 2014
here i have an assignment, creating a longInt class and using it to calculate large numbers, i dont have a clue how to manipulate a whole array as a single ineteger.
View 7 Replies
View Related
May 20, 2013
I'm trying to create a Makefile for a single fie ( mycod.c)
What is the syntax?
View 2 Replies
View Related
Nov 13, 2013
I have an MFC application(.exe) in which i am creating an pointer object to CComQIptr<chemst::IChems>myinfo and after this i have using cocreate instance i had created the object launching that object, so Where i am using that CComQIptr object.
I have been creating instance to that COM exe (child exe) and at the end of the function i am releasing that object (myinfo->release).i want to create single instance for it and i want to use them in different .cpp files and finally i want to kill the child exe. Even though i release the object it is still alive.(Visualising in Task manager whether the exe is still alive or not).
View 1 Replies
View Related
Jun 3, 2013
i have mathematic operation and the result is near 70 digits....single variable cannot hold it....
View 4 Replies
View Related
Apr 18, 2015
I am supposed to make a histogram. I succeeded in generating the integers for the histogram. But what I want to do is instead of displaying numbers in the console, I want something like "*" displayed for every integer there is in an array. It should look something like this.
*
****
*****
********
**********
******
****
***
*
As far as I understand, in some way I need to identify the integer in the array and for every single one of them I need to insert the symbol. I don't know how to identify it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1{
class Program {
static void Main(string[] args) {
diceHistogram();
[Code] .....
View 2 Replies
View Related
Oct 15, 2014
How i can concatenate two integers into one integer. I have code that concatenate two integers but if the 2nd integer is zero it won't work. How can i modify it so that it can cater the case of y=0 too.
Code:
int concatenate(int x, int y) {
int pow = 10;
while(y >= pow)
pow *= 10;
return x * pow + y;
}
View 12 Replies
View Related
Nov 5, 2013
Using a do-while loop, for loop, or while loop. This is what I have so far but i don't know what to do after that.
#include <iostream>
using namespace std;
int main() {
int num;
int min = 2;
int max = 256;
}
Also the results should be printed out with 10 integers per line, right justified in a 5 byte field.
View 1 Replies
View Related
Dec 2, 2014
So I have a simple calculator that does a few operations (+ - * / %) Pretty basic stuff
I declared int x, y for the numbers, char operation, and float result.
the code is based on switch(operation)
The program is running alright, but when I divide 8/7 it returns 1 as the result, I tried changing the x and y to float but that won't work because of the case '%'
I also tried making local float variables in the case'/' but it won't compile "E2126 Case bypasses initialization of a local variable"
How can I make the division work and return a float value?
View 3 Replies
View Related
Jan 24, 2015
Given an integer, find the sum of all the digits in the number until the sum becomes a single digit. E.g. sum of digits of 9264 = 21. Then sum of 21 = 3.
View 2 Replies
View Related
Jun 2, 2013
what I need is to get the first integer from a file and assign it to a variable and the others integers to an array. Example: Thats my file content 5 4 6 7 8 0 and that would be the code:
Code:
struct Array{
int n;
int *v;
}
[code]....
View 8 Replies
View Related
Mar 25, 2014
I got everything in this code running except for my remove function. What the project does is adds or removes an integer to a chain of integers created by the user. My add function works the first time but after that if I try to remove or add I believe it is pointing to the improper location and I don't know how to fix this....
Here is my code:
Header:
// adds "number" to the array pointed to by "arrayPtr" of "size".
// Note the size of the array is thus increased.
void addNumber(int *& arrayPtr, int number, int &size);
// removes a "number" from the "arrayPtr" of "size".
// if "number" is not there -- no action
[Code] .....
View 12 Replies
View Related
Oct 30, 2013
How would i get the total amount of elements From the input file(The .dat file) and then store them in a variable?Here is an example to show you what i want. If a line on the .dat file looked like this
1 2 3 4 5 6 7
How would i find the total number of elements? For example the total number of elements in this line would be 7.
View 9 Replies
View Related
Sep 4, 2013
how can I create a program that will accept 2 two integers. the user will also choose among the different operations:
1 for addition
2 for subtraction
3 for multiplication
4 for division
View 4 Replies
View Related
Feb 10, 2015
1. Write a c++ program to create a vector of integers. copy the vector contents into list, sort the contents, then copy selected items into another vector(like elements less than 10 etc)
View 1 Replies
View Related
Nov 19, 2013
I know it would be easier to create an int array, but I want the program to create integers as the user requests. For example, if the user enters 4, the program creates 4 integers with the names input. Each integer is better as an individual integer, not an element in an array.I'm not sure if this is a possibility with C++.
View 3 Replies
View Related
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 24, 2014
This is my code!! but it's not working at all.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main () {
ofstream fout("datain.txt",ios::out);
int array[6][6];
[Code] .....
View 5 Replies
View Related
Mar 20, 2014
I need to create a program that lists off each digit of an integer and then display the sum off all the digits in that integer. I know that sepereatly the sum function i wrote works. But the first part which i try to list off the digits work but in reverse order which i dont know how to correct. and for some reason that i cant figure out this is affecting the sum output.
#include <iostream>
using namespace std;
int digcount (int x) {;
[Code]....
View 5 Replies
View Related
Oct 17, 2014
i need to create a new integer data type called BigInt to store a big big integer, which includes Dint(8 bytes) and Qint(16 bytes)
here is the hint/
typedef struct BigInt {
Int data[2];
}
How can i "scanf" and "printf" them????
void ScanBigInt(const char *format, BigInt &x)
if format is “%dd” -> input Dint, if format is “%qd”--> input Qint
void PrintBigInt(const char *format, BigInt x)
View 3 Replies
View Related
Dec 2, 2012
i dont usually write console programs, and i cant seem to find out how one parses an unknown number of arguments with cin.
the program receives an unknown amount of integers in stdin, and i need to parse them withouth hanging.
Unfortunately, stdin is a async. stream and blocks, if it doesnt find any integers left.
I cant use peek() or seek() either, as both are async, too, (which makes me wonder what their exact use is?).
View 3 Replies
View Related
Feb 2, 2015
I'm writing code to create an array of integer and let user input choice to display, replace, add new element, etc.I created a header file in the header file there's a function:
Code:
int display_one_element(int* array, int num_of_elements, int position) {
if(num_of_elements < position || position < 0) {
printf("Position out of bound.
");
return 1;
}
return array[position-1];
}
in main I write a function call:
Code:
display_one_element(array, *p_num_elements, position);
My code seems to work fine but there's an error message right next to my function call:
1.too many arguments provided to function like macro invocation
2.Expression result unused
I tried to move the function from header file to c source file. but other functions in the header file works fine and this doesn't work with the error message.
View 3 Replies
View Related
Feb 17, 2013
My question is are there various ways that I can approach this program. I.e. do I have to use switch statements?
/*
NumToTxt
Creates the appropriate word form of any positive integer up to 999999
*/
#include <iostream>
using namespace std;
//represents the largest array size for the user entered number
const int MAXNUMARRAY = 6;
/*represents the largest number that can be entered + 1. Used to calculate the first number used to truncate the user
entered number and to display an error message to the user that tells the user the largest number that the program will
accept. */
const int BIGGESTNUMBER = 1000000;
[Code] .....
View 1 Replies
View Related