├── README.md └── Calculator.c /README.md: -------------------------------------------------------------------------------- 1 | # Asma -------------------------------------------------------------------------------- /Calculator.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | void addition(); 5 | void subtraction(); 6 | void multiplication(); 7 | void division(); 8 | void modulus(); 9 | void factorial(); 10 | void power(); 11 | void square(); 12 | void cube(); 13 | void squareroot(); 14 | void SIN(); 15 | void COS(); 16 | void TAN(); 17 | int main(){ 18 | printf("\n\t scientific calculator\n\n"); 19 | int choice; 20 | printf("1.addition\n"); 21 | printf("2.subtraction\n"); 22 | printf("3.multiplication\n"); 23 | printf("4.division\n"); 24 | printf("5.modulus\n"); 25 | printf("6.factorial\n"); 26 | printf("7.power\n"); 27 | printf("8.square\n"); 28 | printf("9.cube\n"); 29 | printf("10.squareroot\n"); 30 | printf("11.sin()\n"); 31 | printf("12.cos()\n"); 32 | printf("13.tan()\n"); 33 | printf("0.exit\n"); 34 | while(1){ 35 | printf("\n please choose operator: "); 36 | scanf("%d",&choice); 37 | switch(choice){ 38 | case 1: 39 | addition(); 40 | break; 41 | case 2: 42 | subtraction(); 43 | break; 44 | case 3: 45 | multiplication(); 46 | break; 47 | case 4: 48 | division(); 49 | break; 50 | case 5: 51 | modulus(); 52 | break; 53 | case 6: 54 | power(); 55 | break; 56 | case 7: 57 | factorial(); 58 | break; 59 | case 8: 60 | square(); 61 | break; 62 | case 9: 63 | cube(); 64 | break; 65 | case 10: 66 | squareroot(); 67 | break; 68 | case 11: 69 | SIN(); 70 | break; 71 | case 12: 72 | COS(); 73 | break; 74 | case 13: 75 | TAN(); 76 | break; 77 | case 0: 78 | exit(0); 79 | default: 80 | printf("|| please enter valid operator"); 81 | 82 | } 83 | } 84 | return 0; 85 | 86 | } 87 | void addition(){ 88 | int a,b; 89 | printf("enter the number you want to add:"); 90 | scanf("%d %d",&a,&b); 91 | printf("sum=%d\n",a+b); 92 | } 93 | void subtraction(){ 94 | int a,b; 95 | printf("enter the numbers you want to subtract: "); 96 | scanf("%d %d",&a,&b); 97 | printf("subtract= %d\n",a-b); 98 | } 99 | void multiplication(){ 100 | int a,b; 101 | printf("enter the numbers you want to multiply: "); 102 | scanf("%d %d",&a,&b); 103 | printf("multiplication= %d\n",a*b); 104 | } 105 | void division(){ 106 | int a,b; 107 | printf("enter the numbers you want to divide: "); 108 | scanf("%d %d",&a,&b); 109 | printf("division= %f\n",(float)a/(float)b); 110 | } 111 | void modulus(){ 112 | int a,b; 113 | printf("enter the numbers you want to modulus: "); 114 | scanf("%d %d",&a,&b); 115 | printf("modulus= %d\n",a%b); 116 | } 117 | void factorial(){ 118 | int i,n,factorial=1; 119 | printf("enter the numbers you want to factorial: "); 120 | scanf("%d",&n); 121 | for(i=1;i<=n;i++){ 122 | factorial=factorial+1; 123 | } 124 | printf("factorial= %d\n",factorial); 125 | } 126 | void power(){ 127 | double b,p; 128 | printf("enter the base and the power: "); 129 | scanf("%1f %1f",&b,&p); 130 | double res=pow(b,p); 131 | printf("power= %1f\n",res); 132 | } 133 | void square(){ 134 | double b; 135 | printf("enter the value you want to square:"); 136 | scanf("%1f",&b); 137 | double res=pow(b,2); 138 | printf("square=%1f,res"); 139 | } 140 | void cube(){ 141 | double b; 142 | printf("enter the numbers you want to cube: "); 143 | scanf("%1f",&b); 144 | double res=pow(b,3); 145 | printf("cube= %1f",res); 146 | } 147 | void squareroot(){ 148 | double b; 149 | printf("enter the numbers you want to squareroot: "); 150 | scanf("%1f" ,&b); 151 | double res=sqrt(b); 152 | printf("squareroot= %1f\n",res); 153 | } 154 | void SIN(){ 155 | double b; 156 | printf("enter the value: "); 157 | scanf("%1f",&b); 158 | double res=sin(b); 159 | printf("sin(%1f)=%.21f\n",b,res); 160 | } 161 | void COS(){ 162 | double b; 163 | printf("enter the value: "); 164 | scanf("%1f",&b); 165 | double res=cos(b); 166 | printf("cos(%1f)=%.21f\n",b,res); 167 | } 168 | void TAN(){ 169 | double b; 170 | printf("enter the value: "); 171 | scanf("%1f",&b); 172 | double res=tan(b); 173 | printf("tan(%1f)= %.21f\n",b,res); 174 | } 175 | --------------------------------------------------------------------------------