C++ :: Calculator That Takes Two Large Numbers In Linked List Then Ask User To Add Or Subtract

Dec 30, 2012

What I'm trying to do is make a calculator that takes two large numbers in a linked list then ask the user if they wish to add them or subtract them.

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

class Node {
public:
int value;
Node * next;

[Code] ....

View 5 Replies


ADVERTISEMENT

C++ :: How To Write A Function That Takes Two Linked List As Input Arguments

Dec 7, 2012

How do I Write a function that takes two linked list as input arguments these linked list contain numbers like this:

num1->3->5->2->NULL (assuming that number 1 is 352)
num2->4->3->9->1->NULL (assuming that number 2 is 4391)

The function should return 1 if num1 points to a linked list which represents a smaller number than the number pointed to by num2 linked list. Otherwise, it returns -1. If both linked list point to exactly the same number, returns a 0.

View 3 Replies View Related

C :: Program That Takes A Large Text File As Input

Nov 7, 2014

I am writing a spell checker for a exercise for a class I am taking online. I have to load a huge text file of 143092 words into a hash table.

The program segfaults on word number 63197. Is there a way to debug this in gdb without having to step threw the function 63197 times.

View 3 Replies View Related

C :: Addition And Subtraction Calculator That Takes Input?

Feb 23, 2013

I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?

Code:

#include <stdio.h>
int main(int argc, char *argv[]){
int number, sum = 0;

[Code]....

View 3 Replies View Related

C/C++ :: How To Subtract Two String Containing Numbers

Mar 29, 2014

I have a code for subtract of two char arrays(size of each is 50).but i want to write this program with string and i should be consider that size of each string may be not equals.for example we have s1=4777 and s2=55.and we should be subtract them. This is my code.

char* sub(char x[50],char y[50]) {
int i,j,temp=0;
char z[50]={'0'};
for(i=0;i<50;i++)

[Code] .....

View 9 Replies View Related

C :: Linked List - Allow User To Add A New Node

Aug 12, 2013

I'm trying to impliment a simple singly linked list, then allow a user to add a new node. I have mocked up a siimple example to illustrate my point using Linked Lists...

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
int x;
struct node *next;

[Code] ....

So I have done things similatr to this in C# and Java but not in C. There maybe some parts of this I'm sure some will disagree with in terms of buffers,overflow etc. but it's just the linked list part that I am interested in at the moment, I am only doing it like this because when it works, I will be extracting the working linked list stuff into another program that can deal with its I/O etc.

I have tried to comment as best I can to demonstarte my intentions and understandings per line of code. The add function needs to add a node of value x that the user has input, and add that to the end of the list - I'm sure that the print function is not doing all its supposed to do...

View 4 Replies View Related

C/C++ :: Linked List Inputs From The User?

Sep 8, 2014

#include <iostream>
using namespace std;
void insert(int data, int positionOf_n);
void print();
struct node {
int data;
struct node *next;

[code]....

this is the original code which use the insert function call in the main as predefined that doesn't allow the user to input the value that they want

#include <iostream>
using namespace std;
void insert(int data, int positionOf_n);
void print();
struct node {
int data;

[code]....

and this the code which i tried to replace the limitation of the above code by using two for loops in the main function instead of the <insert(5,2)> from the above code which allow the user to insert it own values to the linked list, but it keeps crashing.

View 4 Replies View Related

C++ :: Linked List Won't Take Big Numbers

Jan 2, 2013

My program is almost done all that is left is entering big numbers, the program can add and subtract small numbers but not big numbers because it puts them all in one node, I need the program to store each number in a node.

#include<iostream>
#include<string>
using namespace std;
class Node {
public:
int value;
Node * next;

[Code] .....

View 11 Replies View Related

C++ :: Take Numbers And Add One By One As Integers In Linked List

Aug 21, 2013

Let's say that in a txt file named hot.txt, I have this:

12,23,32

And with ifstream I want to take those number, adding one by one as integers in a linked list.

ifstream myList;
char* p= new char;
cin>>p;
myList.open(p);

if(myList.is_open()) {
char* x =new char;

[Code] ....

I know this part is quite wrong :

myList.get(x,256,','); // dafaq
int num=atoi(x);
list->addOrdered(num);

What I wanted to do is to stop before each comma and take that character and store it in the linked list and continue until the end of the file, but I couldnt.

View 6 Replies View Related

C/C++ :: Using Linked List To Store Guessed Numbers

Apr 26, 2015

Rewriting a program to convert an array based list to a linked list. The program has a user guess a number [1-100] until the correct answer is guessed. I only want to give hints if a duplicate isn't guessed.

while (aGuess-> != p->guess) doesn't work and I haven't been able to troubleshoot myself.

while (aGuess->guess != p->guess) {
if ( aGuess->guess > a ) {
cout << "That's too high -- try again: ";
} // if guess > a

[Code] ....

View 1 Replies View Related

C++ :: Input Data Of Object From User And Then Insert It In Linked List

May 16, 2013

Error:
--------------------Configuration: nc - Win32 Debug--------------------
Compiling...
cv.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/nc.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

nc.exe - 2 error(s), 0 warning(s)

Compiles with 0 error but on running 2 Errors appear.

I'm Inputting data of an object from user and then inserting it in the link list.

#include <iostream>
//#include <fstream>
using namespace std;
#define LEN 100
////////////////////////////////////////////////////////////////////////////////////////////////////
class employee{

[Code] ....

View 1 Replies View Related

C++ :: How To Randomly Insert Certain Numbers Into Linked List With 10 Nodes

Feb 8, 2014

How to randomly insert certain numbers into a linked list with 10 nodes. Meaning I want to put for example numbers 1 5 10 15 20 25 30 35 40 50 in random locations in the linked list.

View 1 Replies View Related

C++ :: Import A File Containing Words And Numbers To Linked List - Bubble Sorting

Feb 16, 2013

I have a code able to import a file containing words and numbers to a linked list, but I also need to sort this linked list alphabetically. I've done research on this involving bubble sorting, but no explanationcan achieve this objective.

Below is the code that can only put the file into linked list:

Code:
#include<iostream>
#include<conio.h>
#include"U:C++WordClass2WordClass2WordClass.cpp"
#include<fstream>
#include<vector>
#include<string>
using namespace std;

[Code] .....

View 5 Replies View Related

C# :: User Class Does Not Contain Constructor That Takes 2 Arguments

Feb 10, 2014

I am having trouble creating a new User from my User Class. The error I am recieving:

Error3'HospitalSystemBL.User' does not contain a constructor that takes 2 argumentsC:UsersStudentdocumentsvisual studio 2010ProjectsHospitalSystemHospitalSystemLogin.aspx.cs2131HospitalSystem

In my User class, I have two constructors. Default and an overloaded constructor.

//default constructor
public User() {
}
//overloaded
public User(long UserName, string Password)

[Code] ....

I am trying to create my user in my Login class. Why is the error saying "does not contain a constructor that takes 2 arguments" when I have a constructor (above), User passing two arguments: UserName and Password? Here is my code for the login:

protected void btnLogin_Click(object sender, EventArgs e) {
try {
int Userid = Convert.ToInt32(txtUser.Text);
string password = txtPassword.Text;

[Code] ....

View 11 Replies View Related

C :: Code That Takes Two Arrays From The User And Merge / Sort?

Oct 27, 2013

I'm trying to write a code that takes two arrays from the user (presumably in ascending order) and then passes the sizes of both arrays and a pointer to each to a separate "int* mergeArrays" function that will merge sort the two. I've written a lot of the code, but I can't get it to compile. I get errors: lab6.c: In function "main":

lab6.c:31:14: error: expected expression before "int"
mergeArrays(int* firstArray, int size1, int* secondArray, int size2);
^
lab6.c:31:14: error: too few arguments to function "mergeArrays"

[Code] ....

View 2 Replies View Related

C++ :: Program Which Takes Date And Time Input From The User

Jan 20, 2013

I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:

struct time
{
short year;
short month;
short day;
short hour;
short min;
};

My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.

I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.

View 2 Replies View Related

C++ :: Program Which Takes Input From User And Write It To A File

Jan 15, 2013

A program which takes input from user and write it to a file then it reads data from that file then it should search for specific data such as email adresses or url etc.

View 1 Replies View Related

C/C++ :: How To Sort Through Large List

Aug 12, 2014

What I want to create is a program that sorts through a huge list (millions of lines).

I want it to get rid of any line that contains a word that isn't in an English dictionary.

Example list:

00sdfdsf
ahdadsg
angel
ksjflsjdf
green
green000
carrot

and it would go through millions like that, giving me only:

angel
green
carrot

as my new list.

How could I go about this? What extra programs would I need?

View 9 Replies View Related

C++ :: Program That Takes Several Numbers Into Array Into A Function

Nov 25, 2014

I have to make a program that takes several numbers into an array into a function, and send them back into the main function multiplied by 1.13. This is what I have so far:

#include <iostream>
using namespace std;
void connell(int&n[20])
main() {
int num[20];

[Code] ...

I do not know how to get numbers from an array from a main program to a function.

View 2 Replies View Related

C :: Program That Takes Multiple Integers From User And Finds Minimum Value

Jun 11, 2014

Write a C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.

This is a sample output. Notice how the program prints a counter (1, 2, 3, ) for user keep track of how many numbers were entered so far. Include this feature in your program.

I have tried different ways to get the result from while loops, do while, and if-else statements. We have not done any max/min problem in class and the book was kind of vague. We have not learned arrays yet in class and I can't figure a way to compare the integers the user inputs as it is an infinite(from what I am reading) amount aloud. The problem I am seeing is the loop works and stops with the sentinel value but the INT_MIN is using the sentinel value. I also have not addressed the input of negative numbers yet with the first program I wrote, maybe one of my problems.

Code:
/*File:HW2Q3.c,
A C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.*/
/*header files*/
#include<stdio.h>
#include<limits.h>
/*****start program*****/
int main() {

[Code] ....

I have also tried this way as well, min value still comes back as -1 the sentinel value, and the else statement is being ignored. I am sure it is something silly but I am lost and confused at this point.

Code:
/*File:HW2Q3.c,
A C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.*/
/*header files*/
#include<stdio.h>
#include<limits.h>

[Code] ....

View 13 Replies View Related

C++ :: Adding Large Numbers?

Apr 5, 2013

I have to make a function that can add two numbers of any size. So far I have:

#include <iostream>
#include <string>
struct number {

[Code]....

why I'm getting a segmentation fault? It's really dense because of all the conversions I had to do.

View 16 Replies View Related

C/C++ :: Factorial Of Large Numbers

Jul 29, 2014

I have designed a code and still i dont get the desired output ....

#include <iostream>
using namespace std;
int fact(int,int);
int arr[200]={1};
int main() {
int n,t,len=0,i=0,j,a;
cin>>t;

[Code] ....

View 3 Replies View Related

C/C++ :: How To Go About Factoring Large Numbers

May 6, 2014

My code handles smaller numbers well enough, but I need the program to be able at least factor 100!.

#include <stdio.h>
void factorialOutput(unsigned int &n, int fac[]);
unsigned long long factorial(int n);
int main(int argc, const char * argv[]) {
unsigned int t = 0;
int n[101];

[Code] ......

View 9 Replies View Related

C++ :: Finding If A Number Is Prime - Large Numbers

Sep 15, 2013

I have a very large number in word ~6million digits long

I wish to make a program to check if it is prime.

View 5 Replies View Related

C++ :: Adding Large Numbers And Calculate Module

Sep 7, 2013

Exmaple:
112121276783621784678236478236478623784672364782367846237846782364782367846238 + 783627846782364786237846782364782367846237846782364782367846237846237864782367846238

It should be efficient and fast. It is useful to calculate the Factorial 100000, and then I calculate the number of the module.

Example:
132142344564378657834657834657863785634786578346578346785634785678653478 % 124623874

View 2 Replies View Related

Visual C++ :: Solving Factorials - Large Numbers?

Nov 21, 2013

If i m writing a code for a program to solve factorials, what is the best approach if i have large numbers in mind?

If i use int, i can only go upto 4bytes and if i use double i can go upto 8bytes. so should i create new type or is there any other way to get this done.

View 14 Replies View Related







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