User Tools

Site Tools


dydaktyka:cprog:2016:functions-solutions

This is an old revision of the document!


Funkcje - rozwiązania i odpowiedzi

Laboratorium: Funkcje

Zadanie GREET

greet.c
#include <stdio.h>
#include <stdlib.h>
 
void greet(int n) {
    int i;
 
    for (i = 1; i <= n; i = i + 1) {
        printf("Dzien dobry!\n");
    }
}
 
int main()
{
    greet(3);
 
    return 0;
}

Zadanie LOGOP-1

logop-1.c
#include <stdio.h>
 
int main()
{
    double a, b, c;
 
    printf("Podaj trzy liczby: ");
    scanf("%lf %lf %lf", &a, &b, &c);
 
    if (a > 0 && b > 0 && c > 0) {
        printf("Trzy dodatnie!\n");
    } else if ((a > 0 && b > 0 && c <= 0) || (a > 0 && b <= 0 && c > 0) || (a <= 0 && b > 0 && c > 0)) {
        printf("Dwie dodatnie!\n");
    } else {
        printf("Nic :(\n");
    }
 
    return 0;
}
dydaktyka/cprog/2016/functions-solutions.1477727992.txt.gz · Last modified: 2020/03/25 11:46 (external edit)