Layout studs
Divide the wall length by the spacing, round down, and add one for the stud at the start: 240 in ÷ 16 in = 15, + 1 = 16. At 24 in on center the same wall takes 240 ÷ 24 = 10, + 1 = 11.
Give the wall length and spacing, the doors and windows and the corners, and see the studs and plate boards to buy as you type, with the cost.
Counts a stud at each end of the wall, then king and jack studs at every opening.
Divide the wall length by the spacing, round down, and add one for the stud at the start: 240 in ÷ 16 in = 15, + 1 = 16. At 24 in on center the same wall takes 240 ÷ 24 = 10, + 1 = 11.
Each side of a door or window gets a full-height king stud and a jack stud under the header: 2 sides × (1 + 1) = 4 more. The IRC, R602.7.5, sets the minimum full-height studs at each end of a header by its span and the wind, from 1 for a 4 ft header; type more where your header needs them.
Corners and the ends of walls that join take extra studs for nailing; how many depends on your corner detail, so the box is yours. Then waste for crooked or split studs: 24 × 1.1 = 26.4, so 27.
The 2021 IRC caps wood stud walls with a double top plate (R602.3.2), with end joints at least 24 in apart, and stands studs on a bottom plate (R602.3.4). So a 20 ft wall takes 3 × 20 = 60 ft of plate: 3.75, so 4 boards of 16 ft.
IRC Table R602.3(5) sets the most a stud may be spaced: a 2 × 4 bearing wall holding up only a roof and ceiling may go to 24 in; one holding a floor as well, 16 in. Then press "Put this on an estimate" to put the studs and plates on the estimate template.
Divide the wall length in inches by the spacing, round down and add one, then add king and jack studs at each opening and extra studs at corners. A 20 ft wall at 16 in on center is 240 ÷ 16 + 1 = 16, plus 4 for a window and 4 for two corners, 24; with 10% waste, 27.
120 ÷ 16 = 7.5, rounded down 7, plus 1 is 8 studs before openings, corners and waste.
The 2021 IRC, Table R602.3(5), allows 2 × 4 studs in a bearing wall at up to 24 in when they hold up only a roof and ceiling, and up to 16 in when they also hold a floor. 2 × 6 studs may go to 24 in for one floor. Your local code and your plans decide.
The IRC calls for a double top plate on wood stud walls (R602.3.2) and a bottom plate under the studs (R602.3.4), so three rows the length of the wall. A single top plate is allowed only under the exception in R602.3.2.
A king stud and a jack stud on each side is 4 for most window headers. The IRC, Table R602.7.5, asks for more full-height studs at each end of longer headers, for example 2 at a 6 ft header where the design wind speed is below 140 mph in Exposure B.