Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###### ####### ###### # # # ####### ### # # #
- # # # # # # # # # # # # # ## #
- # # # # # # # # # # # # # # # #
- ###### ##### ###### ####### # # # # # # # # #
- # # # # # # ####### # # ####### # # #
- # # # # # # # # # # # # # ##
- # ####### # # # # # # # ### # # # #
- Coding ini dibuat hanya untuk rujukan.Bukannya untuk ditiru bulat².
- Sila buat tutorial anda sendiri.Usaha tangga kejayaan.
- Question 3
- #include<stdio.h>
- void mph_to_kmph(float);
- void kmph_to_mph(float);
- int main(void)
- {
- int check,sentinel;
- float ans,input;
- sentinel=1;
- while(sentinel==1)
- {
- printf("If you would like to convert from MPH to KMPH,please enter \"1\" and if you would like to convert from KMPH to MPH,please enter \"2\" : ");
- scanf("%i",&check);
- switch(check)
- {
- case 1:
- printf("\nPlease enter the speed in MPH : ");
- scanf("%f",&input);
- kmph_to_mph(input);
- break;
- case 2:
- printf("\nPlease enter the speed in KMPH : ");
- scanf("%f",&input);
- mph_to_kmph(input);
- break;
- }
- printf("\n\nDo you want to continue converting ?\n1 for continue\n");
- scanf("%i",&sentinel);
- }
- return 0;
- }
- void kmph_to_mph(float input)
- { float ans;
- ans=input/1.609344;
- printf("\n%f mph is equal to %f kmph",input,ans);
- }
- void mph_to_kmph(float input)
- { float ans;
- ans=input*1.609344;
- printf("\n%f kmph is equal to %f mph",input,ans);
- }
- Question 4
- #include<stdio.h>
- #include<math.h>
- #define PI 4.0*atan(1.0)
- float degree_to_radian(int);
- int main(void)
- {
- float radian;
- int degree;
- degree=0;
- printf("Degree\tRadian\n");
- while(degree<360)
- {
- degree+=5;
- radian=degree_to_radian(degree);
- printf("\n%i\t%f",degree,radian);
- }
- return 0;
- }
- float degree_to_radian(int degree)
- { float radian;
- radian=degree*(PI/180);
- return radian;
- }
- Question 5
- #include<stdio.h>
- #define c 2.9979E8
- void energy(float);
- int main(void)
- {
- float mass;
- printf("Please enter the value of mass (kg) : ");
- scanf("%f",&mass);
- energy(mass);
- }
- void energy(float mass)
- { float E;
- E=mass*c*c;
- printf("\nThe energy required for %.2f kg is %.2E",mass,E);
- }
- Question 6
- #include<stdio.h>
- #include<math.h>
- float area(float,float,float,float);
- float s(float,float,float);
- int main(void)
- {
- int sentinel;
- float a,b,c,S,AREA;
- //LOOP BEGIN
- do{
- //Asking user data (input)
- printf("Please enter value of a : ");
- scanf("%f",&a);
- printf("Please enter value of b : ");
- scanf("%f",&b);
- printf("Please enter value of c : ");
- scanf("%f",&c);
- //Assigning value to "S"
- S=s(a,b,c);
- //Calculating AREA
- AREA=area(S,a,b,c);
- printf("\nThe S value is %f,and the area of the triangle is %f",S,AREA);
- printf("\nDo you want to continue ? Hit 1 to continue : ");
- scanf("%i",&sentinel);
- }while(sentinel==1);
- //LOOP ENDS
- return 0;
- }
- float s(float a,float b,float c)
- {float S;
- S=(a+b+c)/2;
- return S;
- }
- float area(float S,float a,float b,float c)
- {float AREA;
- AREA=sqrt(S*(S-a)*(S-b)*(S-c));
- return AREA;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement