Program to add function for long integer

Assignment Help Programming Languages
Reference no: EM13948498

Long interger linked list add function

Posting I am working on program assignment in structures (c language)after entering the required intergers the add function will not compile.I receive error messages I am using a Microsoft c, c++ 6.0 compiler. The help required is to provide a working add function in c. Hopefully after that I will be be able to write similar functions to subtract multiply and divide.

The given problem requires that an add function be provided that should add two given lists n and m.

The source code of the problem is attached

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node
{
int data; // char field data
struct node* next; //pointer field next
}NODE,*NODEP,**NODEPP; //defines three common types

// Function prototypes

void addhead(NODEPP listp,int value);

void getinput1( NODEPP );

void getinput2( NODEPP );
void showtext ( char* );
void showlist( char*,NODEP);
void add_list( listp );
void add();
void subtract();
void multiply();
void divide();
void main (void)
{

char cmd;

showtext(" Enter a to add, s to subtract, m to multiply , d to divide,q when finished");
for (;;)
{
scanf("%c",&cmd);

switch(cmd)
{
case 'a': add(); //addition

break;
case 's': subtract(); // subtract
break;
case 'm':multiply(); //multiply
break;
case 'd':divide(); //divide
break;
case 'q':
exit(0);
break;
}
showtext("nEND OF RUNn");
}

}// end of main

// Adds new node at the heaad of the list. puts value in the data field

void addhead(NODEPP listp, int value)
{

NODEP p = (NODEP)malloc( sizeof (NODE));
p->data = value; // Data Field gets value
p->next = *listp; // links p node to old head
*listp = p; // makes p a new head node
}

void getinput1( NODEPP listp ) //creats a linked list containing numbers
{ // entered by the user.(uses add_to_list)

int n;

printf("Enter a series of integers (! when finished ):");

while((scanf("%d",&n))==1)

addhead(listp,n); //Add new node to list

}

void getinput2( NODEPP listp) //creats a linked list containing numbers
{ // entered by the user.(uses add_to_list)

int m;

printf("Enter a second series of integers (! when finished ):");

while((scanf("%d",&m))==1)

addhead(listp,m); //Add new node to list

}

void showtext ( char* string ) //Displays text
{

printf(string);

}

void showlist(char* string, NODEP list) // Prints list to screen
{

int i =1;
showtext(string);
while (list !=NULL)
{
printf( "%5d",list->data);
if(i++% 10 ==0)showtext("n");
list =list->next;
}
showtext("n END OF LISTn");

}

void add(NODEPP listp ) //add function
{
NODEP n= NULL;
NODEP m =NULL;
NODEP t= NULL;

int tPtr;
tPtr=&t;
showtext( "**INITIAL LIST DATA**n");

getinput1( &n);
showlist("List 1n",n);
getchar();

getinput2( &m);
showlist("List 2n",m);

getchar();

while(t!=0)
{
t->data= n->data+m->data;
}

showlist( "The sum of List 1 and List 2 is:n",t);
}
void subtract(NODEPP listp)

{

}

void multiply()
{

}

void divide()
{

}

Reference no: EM13948498

Questions Cloud

Creates a series of random 2d objects : Part 1: Create a program (OpenGL, or DirectX) that creates a series of random 2D objects, (or 3D objects that only move in 2D), about 25 is probably good but you may need more or less and has them move around on the screen, they should wrap around..
Determine the angular velocity of the disk : The 10-g bullet having a velocity of 800 m>s is fired into the edge of the 5-kg disk as shown. Determine the angular velocity of the disk just after the bullet becomes embedded into its edge. Also, calculate the angle u the disk will swing when it..
Replace the letter n with the letter g and alter the pointer : Then how do I replace the letter N with the letter G and alter the pointers so that the new letter appears in the list in its proper place in alphabetical order?
Prepare an annual budget for the activity of moving material : Prepare an annual budget for the activity of moving materials, assuming that all of the capacity of the activity is used. Identify which resources you would treat as fixed costs and which would be viewed as variable costs.
Program to add function for long integer : The help required is to provide a working add function in c. Hopefully after that I will be be able to write similar functions to subtract multiply and divide.
Does the test show enough evidence to reject the findings : A newspaper writes" this show that there is roughly a 92 percent chance that the difference between the two counts is due to some irregularity other than simply chance alone" Do you agree with the newspaper's interpretation of the p-value Explain ..
Horizontal and vertical components of reaction : If it is supported by the cable AB and hinge at C, determine the tension in the cable when the truck begins to accelerate at 5 m> s2. Also, what are the horizontal and vertical components of reaction at the hinge C?
Design a normalized relational database management system : Design a completely Normalized Relational Database Management System that meets both the high-level and technical requirements of the web-based project management system.
Prepare a schedule of cash receipts for august and september : Kendall Law Firm has found from experience that 30 percent of its services are for cash. Prepare a schedule of cash receipts for August and September.

Reviews

Write a Review

Programming Languages Questions & Answers

  Explain what purpose it serves

List three debugging techniques, within the debugger, that can be used to locate logical error in the Java code. For each of these tools, explain what purpose it serves and how it relates to the debugging process

  Deisgn driver to test implementation elements to tree

Deisgn a driver to test your implementation. Add various elements to the tree, and then display elements in sorted order. Also, display minimum and maximum element.

  Program that prompts the user to enter the birth rate

This function takes as its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years.

  Create a class that simulates an alarm clock

Store time in hours, minutes, and seconds. Note if time is AM or PM. (Hint: You should have separate private members for the alarm and the clock. Do not forget to have a character variable representing AM or PM.)

  Write program to create n-dimensional array on th runtime

Write a program to create an n-dimensional array on the runtime with the help of pointers. The user will enter on the run time that how many dimensions are required.

  Write a program that reads in a single record

Write a program named printRecord.py that reads in a single record from the first logfile, prints it, and exits - Write the final version of your program; it does what merger.py does and then loops through the records accumulating the op costs. It t..

  Creating loop to find number of items bought based on price

Make a block using a loop that will find the number of items that can be bought based on the price of the item and the total amount available to spend.

  Analyze problem develop a solution

Analyze each problem, develop a solution and implement your solution. Copy and paste your program and a sample output below each problem.

  Describe issues-web site designers when adding multimedia

Describe some of the issues web site designers must consider when adding multimedia to a web site. Consider issues such as bandwidth, server load, or others you consider to be important. Please provide references.

  Prolog program to reads employee-s number

Write a prolog program that reads an employee's number from the keyboard, number of hours worked and an hourly rate of pay.

  Design considerations to comply with ada

Browsing devices that assist people with disabilities, such as an aural browser, are especially dependent on the best use of CSS styles. What design considerations should you be aware to comply with ADA?

  Write program simulate checkout line at supermark

Write the program which simulates checkout line at supermarket. Line is a queue object. Customers( i.e customer objects) arrive in random integer intervals of 1-4 minutes.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd