Hi sahil. It depends on how you constrain the gas in the system. Let's take a look at two extremes:
1) We lock the piston in place so the volume remains constant and can't change. PV = nRT always applies. In this case, the V remains constant so P and T vary according to how much heat is added to the cylinder. To determine how they vary, you apply the first law of thermodynamics and find that dU = dQ. In this case, no work is being done on or by the gas in the cylinder because the volume hasn't changed. This is called an isochoric process. Note I'll use the convention that energy added to the gas is positive, so if heat is added, dU increases. If heat is removed, dU decreases.
This is a special case in which dQ= c
v m dT
2) We allow the piston to slide so that the pressure remains constant. This is called an isobaric process, and work is being done by heating the gas. Again, we can apply the first law of thermodynamics and find dU = Q + W. This equation is written assuming heat added to the gas is positive and work done ON the gas is positive. Sometimes the equation is written dU = Q - W such that heat added to the gas is positive and work done BY the gas is positive such that it is subtracted from dU. This seems to generate a lot of confusion, but simply put, energy added to the gas increases the internal energy and energy removed from the gas decreases the internal energy as shown
https://www.physicsforums.com/library.php?do=view_item&itemid=32". This is the special case in which the gas is doing work on the atmosphere equal to the pressure times area times distance the piston moves through, which equals the pressure times the change in volume.
This is a special case in which dQ= c
p m dT
Note that in both these cases, dQ can be either positive or negative depending on heat flux. If we add heat, the temperature will increase in both cases. But that heat can also leave the cylinder and put the system right back to where it was originally. The process always follows the equation PV = nRT.
There are a wide variety of equations that can be applied to the above 2 cases. In addition, we could imagine an infinite number of different cases simply by applying a spring load of varying spring constant to the piston. Depending on how pressure changes in the volume then, the pressure and temperature would not be the same as other cases, but the gas would still follow the equation PV = nRT.