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; // ModifyingPrint an integer using printf:
printf("%d", score);The int type stores whole numbers.
Challenge
EasyThe variable and the printing line are already written for you.
- Assign the value
50to the integer variablenumber
Your output should look like this:
The value is: 50Try 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;
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
3Operators
Arithmetic OperatorsModulo OperatorIncrement/DecrementAssignment OperatorsRelational OperatorsLogical Operators Part 1Logical Operators Part 2Logical Operators Part 3Recap ChallengePractice on your own: Online C compiler