Test_2 - int main () { int i=2 while(i<20)...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> #include <cmath> using namespace std int main () { for(int i=5 i>0 i--){ for (int j=0 j<i j++) cout<<"* " cout<<endl } } #include <iostream> #include <cmath> using namespace std int main () { for(int i=1 i<=4 i++){ for(int j=1 j<=5 j++) cout<<i<<j<<" " cout<<endl } } #include <iostream> #include <cmath> using namespace std int main () { int a=0, i=12 while (i>0){ a=a+i i=i-2 cout<<a<<endl } } #include <iostream> #include <cmath> using namespace std
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int main () { int i=2 while(i&lt;20) Sheet1 Page 2 i=i*i cout&lt;&lt;i&lt;&lt;endl } sol: 256 #include &lt;iostream&gt; #include &lt;cmath&gt; using namespace std int main () { int a=7 do{ cout&lt;&lt;&quot;This is a test.&quot;&lt;&lt;endl a++ }while(a&lt;5) cout&lt;&lt;a&lt;&lt;endl } int base cout&lt;&lt;&quot;Enter the base&quot;&lt;&lt;endl cin&gt;&gt;base { for(int i=1 i&lt;base i++){ for (int j=1 j&lt;i j++) cout&lt;&lt;&quot;* &quot;&lt;&lt;&quot; &quot; cout&lt;&lt;endl } } return 0 } } sol: right triangle...
View Full Document

Page1 / 2

Test_2 - int main () { int i=2 while(i&amp;amp;lt;20)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online