comparison quickcalc.c @ 1:dfce17cc481b default tip

Autmatic Win32 Porting
author VilyaemKenyaz
date Thu, 28 Sep 2023 13:21:58 -0400
parents 9bf878c59a1d
children
comparison
equal deleted inserted replaced
0:9bf878c59a1d 1:dfce17cc481b
1 // A simple calculator, if no arguments do wizard mode. 1 // A simple calculator
2 2
3 #include <stdio.h> 3 #include <stdio.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <unistd.h> 5 #include <unistd.h>
6 #include <math.h> 6 #include <math.h>
7 7
8 int main(int argc, char* argv[]){ 8 int main(int argc, char* argv[]){
9 9
10 if (argc == 1) { puts("Quickcalculator 1Add 2Sub 3Mul 4Div"); exit(1);} 10 if (argc == 1) { puts("Quickcalculator 1Add 2Sub 3Mul 4Div"); exit(1);}
11 // Get numbers 11 // Get numbers
12 unsigned int value1 = atoi(argv[1]); 12 int value1 = atoi(argv[1]);
13 unsigned int value2 = atoi(argv[3]); 13 int value2 = atoi(argv[3]);
14 14
15 // Determine operation 15 // Determine operation
16 unsigned int operation = atoi(argv[2]); // addition subtraction multiplication division 16 unsigned int operation = atoi(argv[2]); // addition subtraction multiplication division
17 // Do calculation and print 17 // Do calculation and print
18 int finalvalue; 18 int finalvalue;