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

The variable and the printing line are already written for you.

  1. Assign the value 50 to the integer variable number

Your output should look like this:

The value is: 50

Try it yourself

#include <stdio.h>

int main() {
    // An integer variable, it starts at 0
    int number = 0;

    // Your turn: assign the value 50 to it, on the line below


    // Already written for you, this line prints the variable
    printf("The value is: %d\n", number);

    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

Practice on your own: Online C compiler