This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dydaktyka:cprog:2015:basic_stdio-solutions [2015/10/22 08:41] pkleczek [Zadanie 3] |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Interakcja z użytkownikiem - rozwiązania i odpowiedzi ====== | ||
- | |||
- | ===== Zadanie 1 ===== | ||
- | |||
- | <code c> | ||
- | #include <stdio.h> | ||
- | #include <stdlib.h> | ||
- | |||
- | int main() | ||
- | { | ||
- | double a, b, c; | ||
- | double suma, srednia; | ||
- | |||
- | printf("Podaj 3 liczby rzeczywiste (oddzielone spacja): \n"); | ||
- | scanf("%lf %lf %lf", &a, &b, &c); | ||
- | |||
- | suma = a + b + c; | ||
- | srednia = suma / 3; | ||
- | |||
- | printf("Suma to: %.2f\n", suma); | ||
- | printf("Srednia to: %.2f\n", srednia); | ||
- | |||
- | return 0; | ||
- | } | ||
- | </code> | ||
- | |||
- | |||
- | ===== Zadanie 2 ===== | ||
- | |||
- | <code c> | ||
- | #include <stdio.h> | ||
- | #include <stdlib.h> | ||
- | |||
- | int main() | ||
- | { | ||
- | int usds; | ||
- | |||
- | printf("Podaj kwote w dolarach: "); | ||
- | scanf("%d", &usds); | ||
- | |||
- | printf("$%d = %7.2f EUR\n", usds, usds * 0.77); | ||
- | printf("$%d = %7.2f PLN\n", usds, usds * 3.04); | ||
- | |||
- | return 0; | ||
- | } | ||
- | </code> | ||
- | |||
- | ===== Zadanie 3 ===== | ||
- | |||
- | <code c> | ||
- | #include <stdio.h> | ||
- | #include <stdlib.h> | ||
- | |||
- | int main() | ||
- | { | ||
- | char c; | ||
- | |||
- | printf("Podaj znak: "); | ||
- | scanf("%c",&c); | ||
- | printf("Kod ASCII znaku '%c' to %d\n", c, c); | ||
- | |||
- | return 0; | ||
- | } | ||
- | </code> | ||