By default the ds3231 module shows 24hr format. so how to change into 12 hr format can we change editing in .cpp or .h file
Which library are you using? There should be a library function to change the format. No editing of files required.
For instance this DS3231 library has the setClockMode function.
void setClockMode(bool h12); // Set 12/24h mode. True is 12-h, false is 24-hour.