
Hi there! That's a great and very common question when starting to learn about variables in C programming.
To answer your question: You do not need to use int again to change the age variable and print it.
The int keyword is only used when you first declare a variable to specify that the variable is of type integer. Once you've declared the variable, you can change its value without redeclaring its type.
In your example:
#include
int main() {
// Create an int variable and print it
int age = 25; // Declare and initialize the variable
printf("%d ", age);
// Assign a new value and print it
age = 31; // Change the value of the already declared variable
printf("%d", age);
return 0;
} Initially, you declare int age = 25; to create an integer variable age and set its value to 25. After that, you can simply change the value using age = 31; without using int again. The printf function can then print the updated value without any further declarations.
Hope this helps! Feel free to ask if you have any more questions. 😊
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer