obrazky
-

Práca s premennými

  1. Vytvor premenné typu integer, float, double, char a priraď im hodnotu.
    • Vypíš hodnoty premenných pomocou funkcie printf()
    • Vypíš premennú typu char ako typ integer
    • Vypíš premennú typu integer ako typ char
    • Vypíš, koľko bajtov zaberajú premenné v pamäti počítača
  2. Aritmetické operácie
    • Zadefinuj dve premenné typu integer
    • Vypíš výsledky operácií +, -, *, /, %, ++, --
    • Odskúšajte, ako fungujú operátory +=, -=, *= atď.
    • Vypíš premennú s väčšou priradenou hodnotou
    • Porovnávacie operátory ==, !=, <, >, >=, <=
  3. Aký typ premennej by ste použili v nasledujúcich úlohách?
    • Načítajte dve čísla a vykonajte všetky aritmetické operácie.
    • Nájdite druhú odmocninu čísla.
    • Prerátajte dni na týždne a týždne na roky.
    • Vstup: polomer r. Výstup: priemer, obvod a obsah kruhu s polomerom r.
    • Pomocou for cyklu vypíšte malú abecedu.
  4. Zistite hodnotu premennej i, ak pred vykonaním operácie bolo i = 6:
    • i += 5;
    • i -= 3;
    • i *= 2;
    • i /= 4;

Working with Variables

  1. Create variables of the types integer, float, double, and char, and assign values to them.

    • Print the values of the variables using the printf() function.
    • Print a variable of type char as an integer type.
    • Print a variable of type integer as a char type.
    • Print how many bytes the variables occupy in the computer’s memory.
  2. Arithmetic Operations

    • Define two variables of type integer.
    • Print the results of the operations +, -, *, /, %, ++, and --.
    • Try out how the operators +=, -=, *=, etc. work.
    • Print the variable with the larger assigned value.
    • Comparison operators: ==, !=, <, >, >=, <=.
  3. What variable type would you use in the following tasks?

    • Read two numbers and perform all arithmetic operations.
    • Find the square root of a number.
    • Convert days into weeks and weeks into years.
    • Input: radius r. Output: the diameter, circumference, and area of a circle with radius r.
    • Use a for loop to print the lowercase alphabet.
  4. Determine the value of the variable i if i = 6 before performing each operation:

    • i += 5;
    • i -= 3;
    • i *= 2;
    • i /= 4;
-
Copyright © 2008-2026 Miroslava Valíková