One of the methods that has recently been considered by researchers in the field of engineering is the Differential Quadratic Method (DQM), which was introduced by Bellman et al for first time in 1972. This method, is based on the idea of the quadrature integral method, in which the partial differential of a function in a coordinate direction is expressed as the weighted and linear sum of all the values of the function at all nods in the mesh in that direction. Studies have shown that the DQ method provides more accurate results with fewer nods and higher speeds with respect other numerical methods. Nanofluid is formed by adding very fine solid particles in the range of 1 to 100 nanometers suspended in a basic fluid. Nanoparticles are made of materials such as copper, aluminum, potassium, silicon and their oxides and basic fluids are relatively lower conductivity such as water and ethylene glycol. In the present study, the behavior of Newtonian and non-Newtonian nanofluid in a square cavity with heat transfer by differential quadrature method has been investigated. The equations are solved dimensionlessly and the outputs are presented in the form of graphs and contours based on different values of parameters of Rayleigh number, volume fraction and power-law index. Prandtl numbers for Newtonian and non-Newtonian nanofluids are chosen as 6.2 and 100, respectively. The results of this study showed that the DQ method, like other numerical methods such as finite difference, finite volume, etc, has the ability and high accuracy in solving problems for both Newtonian and non-Newtonian nanofluids. During Newtonian nanofluid flow, the maximum values of the vertical and horizontal velocities within the cavity increase with increasing Rayleigh number and decrease with increasing volume fraction. Increasing the Rayleigh number and volume fraction cuase to increase the Nusselt number values on the hot wall. In non-Newtonian nanofluids flow, the maximum values of horizontal and v