This is an old revision of the document!
~~NOTRANS~~
#include <stdio.h> #include <stdlib.h> int main() { int rok; printf("Podaj rok: "); scanf("%d", &rok); if ((rok % 4 == 0 && rok % 100 != 0) || (rok % 400 == 0)) { printf("Rok przestepny\n"); } else { printf("Rok nieprzestepny\n"); } return 0; }
#include <stdio.h> #include <stdlib.h> // Funkcja nazywa sie my_abs() aby nie powodowac konfliktu // z wbudowana funkcja abs() z bilbioteki math.h double my_abs(double x) { if (x >= 0) { return x; } else { return -x; } } int main() { double x; x = 3; printf("abs(%lf) = %lf\n", x, my_abs(x)); x = -5; printf("abs(%lf) = %lf\n", x, my_abs(x)); return 0; }
#include <stdio.h> #include <stdlib.h> int main() { int q; printf("Podaj q: "); scanf("%d", &q); if (20 <= q && q < 40 && q % 3 == 0) { printf("q spelnia zaleznosc\n"); } else { printf("q nie spelnia zaleznosci\n"); } return 0; }
#include <stdio.h> #include <stdlib.h> double zeroCut(double x) { if (x >= 0) { return x; } else { return 0; } } int main() { double x; x = 3; printf("max(%lf, 0) = %lf\n", x, zeroCut(x)); x = -5; printf("max(%lf, 0) = %lf\n", x, zeroCut(x)); return 0; }