#include <stdio.h> /* многострочный комментарий */ void main() { // комментарий до конца строки int x = 13; int y = 4; printf("x + y = %d \n", x + y); // сложение целых чисел printf("x - y = %d \n", x - y); // вычитание целых чисел printf("x * y = %d \n", x * y); // умножение целых чисел printf("x %% y = %d \n", x % y); // остаток от деления целых чисел printf("x / y = %d \n", x / y); // деление целых чисел double a = 11.7, b = 3.5; printf("a / b = %lf \n", a / b); // деление вещ. чисел printf("x + a = %lf \n", x + a); // сложение целых и вещ. чисел char c1 = 10, c2 = 100; printf("c1 + c2 = %d \n", c1 + c2); // пример взаимозаменяемых операторов int i = 15; printf("i = %d \n", i);i = i + 1; printf("i=i+1 : %d \n", i); i++; printf("i++ : %d \n", i); i += 1; printf("i+=1 : %d \n", i); // экспоненциальный формат double d = -5.438754e3, f = 1.3e-7; int dInt = (int) d; printf("d= %lf \n", d); printf("dInt = %d \n", dInt); }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more