Guest User

Untitled

a guest
Jan 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. Enter a number: 7
  2. 7 14 21 28 35 42 49 56 63 70
  3. 77 84 91 98 105 112 119 126 133 140
  4. 147 154 161 168 175 182 189 196 203 210
  5.  
  6. #include<iostream>
  7. #include<iomanip> // For setw()
  8. #include<conio.h> // For getch()
  9. using namespace std;
  10. int main()
  11. {
  12. int number;
  13. cout << "Enter the number whose table you want: ";
  14. cin >> number;
  15. int maxrows; int maxcols;
  16. cout << "nEnter the number of rows you want: "; cin >> maxrows;
  17. cout << "nEnter the number of columns : ";
  18. cin >> maxcols;
  19. int pos=1; //starting position
  20.  
  21. while( pos<=maxrows*maxcols )
  22. {
  23. for(int col=1; col<=maxcols; col++, pos++)
  24. {
  25. cout<< setw(6) << pos*number << " ";
  26. }
  27. cout<<"n";
  28. }
  29. getch();
  30. }
  31.  
  32. #include<iostream>
  33. #include<iomanip>
  34. #include<conio.h>
  35. using namespace std;
  36. int main()
  37. {
  38. int number;
  39. cout << "Enter the number whose table you want: ";
  40. cin >> number;
  41. int maxrows; int maxcols;
  42. cout << "nEnter the number of rows you want: "; cin >> maxrows;
  43. cout << "nEnter the number of columns : "; cin >> maxcols;
  44. int row; int col; //Current row and current col
  45.  
  46. for(int pos=1; pos<=(maxrows*maxcols); pos++)
  47. {
  48. cout << setw(6) <<number*pos << " ";
  49. if((pos%maxcols)==0)
  50. {
  51. cout << "n";
  52. }
  53.  
  54. }
  55. getch();
  56. }
  57.  
  58. #include<iostream>
  59. #include<iomanip>
  60. #include<conio.h>
  61. using namespace std;
  62. int main()
  63. {
  64. int number;
  65. cout << "Enter the number whose table you want: ";
  66. cin >> number;
  67. int maxrows; int maxcols;
  68. cout << "nEnter the number of rows you want: "; cin >> maxrows;
  69. cout << "n Enter the number of columns : "; cin >> maxcols;
  70.  
  71. for(int row=0; row<=(maxrows-1); row++)
  72. {
  73. for(int col=1; col<=maxcols; col++)
  74. {
  75. cout << setw(6) << number*(col + row*maxcols); // (col + row*maxcols) represent the current position
  76. }
  77. cout << "n";
  78. }
  79. getch();
  80. }
  81.  
  82. #include<iostream>
  83. #include<iomanip> // For setw()
  84. #include<conio.h> // For getch()
  85. using namespace std;
  86. int main()
  87. {
  88. int number;
  89. cout << "Enter the number whose table you want: ";
  90. cin >> number;
  91. int maxrows; int maxcols;
  92. cout << "nEnter the number of rows you want: "; cin >> maxrows;
  93. cout << "n Enter the number of columns : ";
  94. cin >> maxcols;
  95.  
  96.  
  97.  
  98. for(int row=1; row<=maxrows; row++ )
  99. {
  100. cout << "n";
  101. for(int col=0; col<maxcols; col++)
  102. {
  103. cout << setw(6)<< number*(row + maxrows*col) << " ";
  104. }
  105.  
  106.  
  107. }
  108. getch();
  109. }
  110.  
  111. for(int row=0; row<=(maxrows-1); row++)
  112.  
  113. for(int row = 0; row <= maxrows - 1; row++)
  114.  
  115. for(int i=0; i < N; ++i) { /* do something */ }
  116.  
  117. for(int row=0; row<=(maxrows-1); row++) {
  118. for(int col=1; col<=maxcols; col++) {
  119. // do stuff
  120. }
  121. }
  122.  
  123. int accum = number;
  124. for(unsigned row = 0; row < maxrows; ++row) {
  125. for(unsigned col = 0; col < maxcols; ++col) {
  126. std::cout << std::setw(6) << accum;
  127. accum += number;
  128. }
  129. std::cout << "n";
  130. }
  131.  
  132. #include <iostream>
  133. #include <iomanip>
  134.  
  135. int main()
  136. {
  137. int number;
  138. std::cout << "Enter the number whose table you want: ";
  139. std::cin >> number;
  140. unsigned maxrows;
  141. unsigned maxcols;
  142. std::cout << "nEnter the number of rows you want: ";
  143. std::cin >> maxrows;
  144. std::cout << "nEnter the number of columns : ";
  145. std::cin >> maxcols;
  146.  
  147. const int colincr = number * maxrows;
  148. const int rowdecr = number * (maxrows * maxcols - 1);
  149. int accum = number;
  150. for(unsigned row = 0; row < maxrows; ++row) {
  151. for(unsigned col = 0; col < maxcols; ++col) {
  152. std::cout << std::setw(6) << accum;
  153. accum += colincr;
  154. }
  155. accum -= rowdecr;
  156. std::cout << 'n';
  157. }
  158. }
  159.  
  160. Enter the number whose table you want: 7
  161.  
  162. Enter the number of rows you want: 5
  163.  
  164. Enter the number of columns : 8
  165. 7 42 77 112 147 182 217 252
  166. 14 49 84 119 154 189 224 259
  167. 21 56 91 126 161 196 231 266
  168. 28 63 98 133 168 203 238 273
  169. 35 70 105 140 175 210 245 280
  170.  
  171. #include <iostream>
  172. #include <iomanip>
  173.  
  174. int main() {
  175.  
  176. int num;
  177. std::cout << "Enter no: ";
  178. std::cin >> num;
  179.  
  180. unsigned int row = 20, col = 10;
  181.  
  182. int sum = 0;
  183. num < 0
  184.  
  185. for( unsigned int i = 0; i < row; ++i) {
  186.  
  187. for( unsigned int j = 0; j < col; ++j) {
  188. sum += num;
  189. std::cout << std::setw(6) << sum;
  190. }
  191. std::cout << 'n';
  192. }
  193.  
  194. return 0;
  195. }
  196.  
  197. for (int i = 0; i < n; i++) {
  198. }
  199.  
  200. for(int row=0; row<=(maxrows-1); row++)
  201.  
  202. int n = 0;
  203. for (int row = 0; row < maxrows; row++) {
  204. for (int col = 0; col < maxcols; col++) {
  205. std::cout << std::setw(7) << (n += multiple);
  206. }
  207. std::cout << "n";
  208. }
  209.  
  210. int stride = maxrows * multiple;
  211. for (int row = 1; row <= maxrows; row++) {
  212. for (int col = 1, n = row * multiple; col <= maxcols; col++, n += stride) {
  213. std::cout << std::setw(7) << n;
  214. }
  215. std::cout << "n";
  216. }
  217.  
  218. #include<iostream>
  219. #include<iomanip>
  220. using namespace std;
  221. int main()
  222. {
  223. int number=0,i,rows,col;
  224. cout << "Enter the number,rows and columns: ";
  225. cin >> number>>rows>>col;
  226. for(i=1;i<=col*rows;i++)
  227. {
  228. if(i%rows==0){
  229. cout<<setw(5)<<number*i<<"n";
  230. }
  231. else{
  232. cout<<setw(5)<<number*i;
  233. }
  234. }
  235. }
  236. I find this code easy to understand as first year student!!
  237.  
  238. date=1 ; while(date <= monthLength)
  239. printf("%2d%c",date++,(date-offset) % 7 ? ' ' : 'n');
Add Comment
Please, Sign In to add comment