Menu
Coddy logo textTech

Integer

Part of the Fundamentals section of Coddy's C journey — lesson 6 of 63.

In C, integers are whole numbers without any decimal points. They are one of the most common data types you'll work with.

Declaring, initializing, and modifying integers:

int age; // Declaring
int score = 100; // Declaring and initializing
score = 90; // Modifying

Print an integer using printf:

printf("%d", score);

The int type stores whole numbers.

challenge icon

Challenge

Easy

Create a program that:

  1. Declares an integer variable named number
  2. Assigns the value 50 to this variable
  3. Prints the value of the variable using printf

Your output should look like this:

The value is: 50

Cheat sheet

Integers in C are whole numbers without decimal points. Use the int data type to work with them.

Declaring, initializing, and modifying integers:

int age; // Declaring
int score = 100; // Declaring and initializing
score = 90; // Modifying

Print an integer using printf with the %d format specifier:

printf("%d", score);

Try it yourself

#include <stdio.h>

int main() {
    // Declare an integer variable named 'number'

    // Assign the value 50 to the variable

    // Print the value using printf

    return 0;
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals