-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx-50_Functions - 3.c
61 lines (61 loc) · 1.44 KB
/
Ex-50_Functions - 3.c
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
#include <stdio.h>
#include <stdlib.h>
//void ,int ,float and char function
//Function Declaration
void printName(char n[20]);
void printWeightHeight(float w,float h);
int calculateSalary();
char getGrade(int m);
int main(){
//For printing name
char name[20];
printf("Enter Your Name :");
fgets(name,sizeof(name),stdin);
//calling
printName(name);
//for printing w & h
printf("------------------------------\n");
float weight,height;
printf("Enter w & h :");
scanf("%f,%f",&weight,&height);
//calling
printWeightHeight(weight,height);
//for calculating salary
printf("------------------------------\n");
int salary=calculateSalary();
printf("Your Salary is %d",salary);
//for getting grade
int marks;
printf("------------------------------\n");
printf("Enter Your marks :");
scanf("%d",&marks);
printf("Your grade is : %c",getGrade(marks));
return 0;
}
void printName(char n[20]){
printf("Your Name is %s",n);
}
void printWeightHeight(float w,float h){
printf("Weigh : %0.2f\n",w);
printf("Height : %0.2f\n",h);
}
int calculateSalary(){
int sal,csal;
printf("Enter salary :");
scanf("%d",&sal);
csal=sal+1500;
return csal;
}
char getGrade(int m){
if(m>=75){
return 'A';
}else if(m>=65){
return 'B';
}else if(m>=55){
return 'C';
}else if(m>=35){
return 'S';
}else{
return 'W';
}
}