Introduction to Programming with C – Basic Exercises

1) Define 3 integer. Let values be 1, 2, 3.

Print out;

a) these numbers,

b) sum of them,

c) multiplication of them,

Desired output:

1 2 3
6
6

2) Read weight(float) and height(int) from keyboard. Calculate the optimal weight for the user with this formula. Print out ideal weight and the excess.

Multiply the height by 3 and substract 250. Divide by 4 the result.

(3*boy-250)/4

Hint: the result variable should be float data type. If it is integer, you will lose data.

Sample input:

75
180

Sample output:

72,5 
2,5

Çözümler:

1)

#include < stdio.h >

int main(){
    int a=1, b=2, c=3;
    printf("%d %d %d", a, b, c);
    printf("%d", a+b+c);
    printf("%d", a*b*c);
    return 0;
}

2)

#include < stdio.h >

int main(){
    float weight, idealweight;
    int height;
    scanf("%f %d", &weight, &height);
    idealkilo = (3*boy-250)/4;
    printf("%f", idealweight);
    printf("%f", idealweight-weight);

    return 0;
}

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


8 + 2 =