salut à tous
J'ai fait ce petit programme qui s'appelle Basic calculator et je souhaiterais avoir votre avis le code source, et d'éventuelle suggestions pour fixer les bugs.
merci d'avance
url : http://beat.byethost13.com/unix/linux.html
Au fait je suis Beat

Edit de Gruik : je poste ici, il est pas gros
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include<stdio.h>
 
/*
*Name : calculator.c
 * Vertion : 0.1
 * Author : Beat
 * 14-sep-2007
 * Description : This application is a basic calculator.
 * 		 It has another interesting feature : print multiplication table accordin to user input.
 * 		 Operators used to perform operations are :
 * 		 + addition
 * 		 - subtraction
 * 		 * multiplication
 *		 / division
 *
 *		 Type -help to see how program works.
 *
 *
 */
 
int calculate(void);
int help(void);
int table(void);
 
int main()
{	
	printf("\t\t\t   -------------------   \n");
	printf("\t\t\t  |  Basic Calculator |  \n");
	printf("\t\t\t   -------------------   \n");
	printf("\t\t\t    | Coded by Beat |    \n");
	printf("\t\t\t     ---------------     \n");
	printf("\t\t\t         Usage :         \n");
	printf("\t\t\t         -------       \n\n");
	printf("\th --help            ->  shows how program works\n\tt --table           ->  prints multiplication table of a number\n\tc --calculate       ->  switch to basic calculating\n\tq --quit            ->  To exit program\n\n\n");
 
	char choice;
	printf("Menu >");
	while(choice != 'q')
	{
 
		scanf("%c", &choice);
 
 
		if(choice == 'h')		
		{	 help();} 
		else if(choice == 't')
		{	 table();}
		else if(choice == 'c')
		{	 calculate();}
		else
		{	printf("Menu >");}
 
 
 
	}
 
	printf("\n\n\n\t\t\tBye ------------------>See you soon !\n\n\n");	
 
 
 
return 0;
}
 
int calculate(void)
{	
	double i = 0, j = 0;
	char operator;
	printf("Calculator >");
	scanf("%lf %c %lf", &i, &operator, &j);
 
	switch(operator)
	{	
		case '+': printf("Result is -> %lf\n", i+j);
			  break;
		case '-': printf("Result is -> %lf\n", i-j);
			  break;
		case '*': printf("Result is -> %lf\n", i*j);
			  break;
		case '/': printf("Result is -> %lf\n", i/j);
			  break;
		default : printf("Bad syntax ! type h for more information");
	}
return 0;
}
 
 
int table(void)
{	
	int i = 0, j = 1, k;
 
	printf("Multiplication Table >");
	scanf("%d", &i);
	while(j<11)
	{	
		k = j*i;
		printf("%d x %d = %d\n", j, i, k);
		j++;
	}
return 0;
}
 
int help()
{	printf("\t\t\t\t\t\t| help |\n");
	printf("\t\t\t\tBasic calculator is, as it's name tells,\n\t\t\t\ta program alowing to do some basic calculations\n\n\n");
	printf("\t-c : This command switchs to calculate mode. type 1st number <space> operator <space> 2nd number.\n              Existing operators : +  *  /  - for addition, multiplication, division and substraction.\n\n");
	printf("\t-t : Shows multiplication table of an number. Just type the number and press Enter.\n\n");
 
return 0;
}