Created
July 19, 2019 07:10
-
-
Save xkamail/5ae35062caf97506a07ddc5b57e746d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
int demo1(){ | |
int i; | |
printf("#######################\n"); | |
printf("# Insert Employees #\n"); | |
printf("#######################\n"); | |
char genders[3][400] = {}; | |
char age[3][400] = {}; | |
char tel[3][400] = {}; | |
int salary[3][400] = {}; | |
for(i = 0; i < 3; i++){ | |
printf("Insert Employee No.%d\n",i + 1); | |
printf("Enter Gender [M or F]: ",i); | |
scanf("%s",&genders[i]); | |
printf("Enter Age: ",i); | |
scanf("%s",&age[i]); | |
printf("Enter Telephone: ",i); | |
scanf("%s",&tel[i]); | |
printf("Enter Salary: ",i); | |
scanf("%s",&salary[i]); | |
if(i == 2){ | |
for(i = 0; i < 3; i++){ | |
if(i == 0) { | |
printf("\n"); | |
printf("\n"); | |
printf("\n#######################\n"); | |
} | |
printf("# Employee No.%d #\n",i +1 ); | |
printf(" Age: %s\n",age[i]); | |
printf(" Gender: %s\n",genders[i]); | |
printf(" Telephone: %10s\n",tel[i]); | |
printf(" Salary: %s\n",salary[i]); | |
printf("#######################\n"); | |
} | |
} | |
} | |
} | |
int demo2(){ | |
float x,y,z; | |
printf("Please enter x: "); | |
scanf("%f",&x); | |
printf("Please enter y: "); | |
scanf("%f",&y); | |
printf("Please enter z: "); | |
scanf("%f",&z); | |
printf("\n X= %f Y=%f Z=%f\n",x,y,z); | |
int options; // 0 = 2.1 1 = 2.2 | |
printf("Select mathematical expression between 2.1 or 2.2 (1 or 2): "); | |
scanf("%d",&options); | |
if(options == 1){ | |
float result = (x*y) +3 - (7-z); | |
printf("Result is => %.2f\n",result); | |
}else{ | |
x = x*x; | |
float result2 = 3*x + 2*y - 7*z; | |
printf("Result is => %.2f\n",result2); | |
} | |
} | |
int demo3(){ | |
int sum1,sum2; | |
float x,y,z; | |
printf("Please enter x , y , z : "); | |
scanf("%f %f %f",&x,&y,&z); | |
sum1 = (((x * x * x)+(y * y))/(3 * z - 4)) + 2 * x; | |
sum2 = ((-4 * x)+(20 * y)) * z; | |
printf("First equation result : %.2f\n",sum1); | |
printf("Second equation result : %.2f",sum2); | |
} | |
int calculator(){ | |
int price = 0,good = 0,amount = 0; | |
printf("Please enter the price of goods: "); | |
scanf("%d",&good); | |
printf("Please enter the price of pay: "); | |
scanf("%d",&price); | |
amount = price-good ; | |
printf("Charge amount : %d",amount); | |
printf("\n500 Bath : %d",amount /500); | |
amount = amount - (500 * (amount /500)); | |
printf("\n100 Bath : %d",amount/100); | |
amount = amount - (100 * (amount /100)); | |
printf("\n50 Bath : %d",amount/50); | |
amount = amount - (50 * (amount /50)); | |
printf("\n20 Bath : %d",amount/20); | |
amount = amount - (20 * (amount /20)); | |
printf("\n10 Bath : %d",amount/10); | |
amount = amount - (10 * (amount /10)); | |
printf("\n5 Bath : %d",amount/5); | |
amount = amount - (5 * (amount /5)); | |
printf("\n1 Bath : %d",amount/1); | |
amount = amount - (1 * (amount /1)); | |
} | |
int main() | |
{ | |
// demo1(); | |
// demo2(); | |
// calculator(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment