Advertisement
Guest User

Задачи с семинара "Основы и методология программирования""

a guest
Sep 17th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.92 KB | None | 0 0
  1. // Задача 1
  2. #include<stdio.h>
  3.  
  4. int main() {
  5.     float r = 0.0;
  6.     float h = 0.0;
  7.     printf("Enter radius and height: ");
  8.     scanf("%f %f", &r, &h);
  9.     printf("V=%f\n", (3.14 * r  * r * h));
  10.     return 0;
  11. }
  12.  
  13. // Задача 2
  14. #include<stdio.h>
  15.  
  16. int main() {
  17.     float r = 0.0;
  18.     float h = 0.0;
  19.     printf("Enter radius and height: ");
  20.     scanf("%f %f", &r, &h);
  21.     printf("V=%f\n", (2 * 3.14 * r * r) + (2 * 3.14 * r * h));
  22.     return 0;
  23. }
  24.  
  25. // Задача 3
  26. #include<stdio.h>
  27.  
  28. int main() {
  29.     int m = 0;
  30.     printf("Enter time in minutes: ");
  31.     scanf("%d", &m);
  32.     printf("Hours: %d, minutes: %d\n", (m / 60), (m % 60));
  33.     return 0;
  34. }
  35. // Задача 4
  36. #include<stdio.h>
  37.  
  38. int main() {
  39.     float m = 0.0;
  40.     printf("Enter mass in pounds: ");
  41.     scanf("%f", &m);
  42.     printf("Mass in kilos: %f\n", m * 0.4059);
  43.     return 0;
  44. }
  45. // Задача 5
  46. #include<stdio.h>
  47.  
  48. int main() {
  49.     float d = 0.0;
  50.     printf("Enter distance in versts: ");
  51.     scanf("%f", &d);
  52.     printf("Distance in kilometers: %f\n", d * 0.10668);
  53.     return 0;
  54. }
  55. // Задача 6
  56. #include<stdio.h>
  57.  
  58. int main() {
  59.     float r = 0;
  60.     float u = 0;
  61.     printf("Enter resistance and voltage: ");
  62.     scanf("%f %f", &r, &u);
  63.     if (r != 0 ){
  64.         printf("Strength: %f\n", u / r);
  65.     }
  66.     else {
  67.         printf("Strength equals infinity\n");
  68.     }
  69.     return 0;
  70. }
  71. // Задача 7
  72. #include<stdio.h>
  73.  
  74. int main() {
  75.     float p = 0;
  76.     printf("Enter price for 100 gramms: ");
  77.     scanf("%f",  &p);
  78.     printf("Price for kilo=%f\n", 10 * p);
  79.     return 0;
  80. }
  81. // Задача 8
  82. #include<stdio.h>
  83.  
  84. int main() {
  85.     float r1 =0;
  86.     float r2 = 0;
  87.     printf("Enter resistance for 1st and 2nd resistors: ");
  88.     scanf("%f %f", &r1, &r2);
  89.     if((r1 + r2) !=0 ){
  90.         printf("Resistance: %f\n", (r1 * r2) / (r1 + r2));
  91.     }
  92.     else {
  93.         printf("Zeo\n");
  94.     }
  95.     return 0;
  96. }
  97. // Задача 9
  98. #include<stdio.h>
  99.  
  100. int main() {
  101.     float a = 0;
  102.     float b = 0;
  103.     printf("Enter a and b: ");
  104.     scanf("%f %f",  &a, &b);
  105.     printf("S=%f", (a * b));
  106.     return 0;
  107. }
  108. // Задача 10
  109. #include<stdio.h>
  110.  
  111. int main() {
  112.     float m = 0;
  113.     float p = 0;
  114.     printf("Enter mass of apples and price for kilo: ");
  115.     scanf("%f %f",  &m, &p);
  116.     printf("Total price=%f\n", (m * p));
  117.     return 0;
  118. }
  119. // Задача 11
  120. #include<stdio.h>
  121.  
  122. int main() {
  123.     float s = 0;
  124.     float b = 0;
  125.     float p = 0;
  126.     // printf("Enter mass of apples and price for kilo: ");
  127.     scanf("%f %f %f",  &s, &b, &p);
  128.     if(b !=0 ){
  129.         printf("Total price=%f\n", (2 * s) / b * p);
  130.     }
  131.     else {
  132.         printf("b cannot be 0");
  133.     }
  134.    
  135.     return 0;
  136. }
  137. // Задача 12
  138. #include<stdio.h>
  139.  
  140. int main() {
  141.     float a = 0;
  142.     float b = 0;
  143.     float c = 0;
  144.     printf("Enter a, b and c: ");
  145.     scanf("%f %f %f",  &a, &b, &c);
  146.     printf("%f", a * b * c);
  147.     return 0;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement