#include <stdio.h>
//we can name anything for set and get funs since its basic fn not any defined
// Private variable
static int age;
// Getter function
int getAge() {// it just return the static value in this file
return age;//can can be accesd from all other files
}
// Setter function
void setAge(int newAge) {//main fun that update the new value;
age = newAge;
}
int main() {
// Using the getter and setter functions
setAge(25);
printf("Age: %d\n", getAge()); // Output: Age: 25
setAge(30);
printf("Age: %d\n", getAge()); // Output: Age: 25
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: