123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Addition of two long positive integers of any length using linked lists

--------------------------------------------------------------------------------

Description : This is one of the important applications of linked
lists.Through this program it is possible to add long integers of any
length may be above 50 digits with the help of Dynamic memory management
technique-The linked lists.

Parameters :Two long positive integers are given as input,the output will
be sum of those two integers represented interms of linked lists.

/*
Addition of two long integers of any length using linked lists
Author: SRINIVASA SARMA B
Email : sarma_433@yahoo.com
*/

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

struct link_list
{
int data;
struct link_list *next;
};
struct link_list *front,*temp,*p,*q,*sum,*k,*s,*stack,*temp1,*temp2;
void push(int);
struct link_list *add(struct link_list *,int);
struct link_list *createlist(struct link_list *,char *);
struct link_list *addint(struct link_list *,struct link_list *);
void display();
void show();

void main()
{
char *str1,*str2;
s=front=p=q=k=NULL;
clrscr();
printf("
Enter the first number:"); /* we read both the numbers as two
strings */
scanf("%s",str1);
printf("
Enter the second number:");
scanf("%s",str2);
p=createlist(p,str1);
q=createlist(q,str2);
sum=addint(p,q);
display();
getch();
}

struct link_list *createlist(struct link_list *node,char *s)
{
char *c;
int i=0;
int data;
strrev(s);
while(i<strlen(s))
{
strncpy(c,s+i,4);
*(c+4)='
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG