-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
81 lines (73 loc) · 2.16 KB
/
Copy pathmain.c
File metadata and controls
81 lines (73 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**************************************************************************************************************************************************************
*Title : main function(Driver function)
*Description : This function is used as the driver function for the all the functions
***************************************************************************************************************************************************************/
#include "apc.h"
#include <stdio.h>
int main()
{
/* Declare the pointers */
Dlist *head1, *tail1, *head2, *tail2, *headR,*tailR;
char option, operator;
do
{
head1=tail1=head2=tail2=headR=tailR=NULL;
/* Code for reading the inputs */
char s[1000];
printf("Enter the Input:\n");
scanf("%s",s);
/* Function for extracting the operator */
operator = findOperator(s);
if(insertElements(&head1,&tail1,&head2,&tail2,s) == SUCCESS)
{
printf("Elements inserted in list\n");
}
switch (operator)
{
case '+':
/* call the function to perform the addition operation */
if(addition(&head1,&tail1,&head2,&tail2,&headR,&tailR) == SUCCESS)
{
printf("The result is \n");
print_list(headR);
}
else
{
printf("INFO: ADDITION FAILED!\n");
}
break;
case '-':
/* call the function to perform the subtraction operation */
if(subtraction(&head1,&tail1,&head2,&tail2,&headR,&tailR) == SUCCESS)
{
printf("The result is \n");
print_list(headR);
}
else
{
printf("INFO: SUBTRACTION FAILED!\n");
}
break;
case '*':
/* call the function to perform the multiplication operation */
if(multiplication(&head1,&tail1,&head2,&tail2,&headR,&tailR) == SUCCESS)
{
printf("The result is \n");
print_list(headR);
}
else
{
printf("INFO: MULTIPLICATION FAILED!\n");
}
break;
case '/':
/* call the function to perform the division operation */
break;
default:
printf("Invalid Input:-( Try again...\n");
}
printf("\nWant to continue? Press [yY | nN]: ");
scanf("\n%c", &option);
}while (option == 'y' || option == 'Y');
return 0;
}