answersLogoWhite

0

A conditional loop will only continue to loop while the given condition is true:

while( i < 10 ) {

...

}

An unconditional loop either has no condition (a GOTO loop), or the condition is guaranteed to always evaluate to true:

while( true ) {

...

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Perform addition multiplication subtraction of 2-D array using Operator Overloading in C plus plus?

#include&lt;iostream&gt; #include&lt;vector&gt; #include&lt;random&gt; template&lt;const size_t R, const size_t C&gt; class Matrix { public: using row_type = int[C]; private: // attributes int m_data[R][C]; public: // construction/assignment Matrix (); Matrix (const Matrix&amp; source); Matrix (Matrix&amp;&amp; source); Matrix&amp; operator= (const Matrix&lt;R,C&gt;&amp; source); Matrix&amp; operator= (Matrix&lt;R,C&gt;&amp;&amp; source); ~Matrix () {} public: // accessors row_type&amp; row (const size_t index) { return m_data[index]; } const row_type&amp; row (const size_t index) const { return m_data[index]; } row_type&amp; operator[] (const size_t index) { return m_data[index]; } const row_type&amp; operator[] (const size_t index) const { return m_data[index]; } size_t size() const { return R * C; } size_t rows() const { return R; } size_t cols() const { return C; } public: // operations Matrix&lt;R,C&gt;&amp; operator+= (const Matrix&lt;R,C&gt;&amp;); Matrix&lt;R,C&gt;&amp; operator-= (const Matrix&lt;R,C&gt;&amp;); }; template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;::Matrix() { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] = 0; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;::Matrix(const Matrix&lt;R,C&gt;&amp; source) { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] = source.m_data[row][col]; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;::Matrix(Matrix&lt;R,C&gt;&amp;&amp; source) { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] = std::move (source.m_data[row][col]); } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;&amp; Matrix&lt;R,C&gt;::operator= (const Matrix&lt;R,C&gt;&amp; source) { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] = source.m_data[row][col]; return *this; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;&amp; Matrix&lt;R,C&gt;::operator= (Matrix&lt;R,C&gt;&amp;&amp; source) { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] = std::move (source.m_data[row][col]); return *this; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;&amp; Matrix&lt;R,C&gt;::operator+= (const Matrix&lt;R,C&gt;&amp; rhs) { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] += rhs.m_data[row][col]; return *this; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt;&amp; Matrix&lt;R,C&gt;::operator-= (const Matrix&lt;R,C&gt;&amp; rhs) { for (size_t row=0; row&lt;R; ++row) for (size_t col=0; col&lt;C; ++col) m_data[row][col] -= rhs.m_data[row][col]; return *this; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt; operator+ (const Matrix&lt;R,C&gt;&amp; lhs, const Matrix&lt;R,C&gt;&amp; rhs) { Matrix&lt;R,C&gt; sum (lhs); return sum += rhs; } template&lt;const size_t R, const size_t C&gt; Matrix&lt;R,C&gt; operator- (const Matrix&lt;R,C&gt;&amp; lhs, const Matrix&lt;R,C&gt;&amp; rhs) { Matrix&lt;R,C&gt; sub (lhs); return sub -= rhs; } template&lt;const size_t R, const size_t C, const size_t R1, const size_t C1&gt; Matrix&lt;R,C1&gt; operator* (const Matrix&lt;R,C&gt;&amp; lhs, const Matrix&lt;R1,C1&gt;&amp; rhs) { static_assert (C==R1, "Matrix dimension mismatch!"); Matrix&lt;R,C1&gt; mul; for (size_t x=0; x!=R; ++x) { for (size_t y=0; y!=C1; ++y) { int prod = 0; for (size_t z=0; z!=C; ++z) { prod += lhs[x][z] * rhs[z][y]; } mul[x][y] = prod; } } return mul; } template&lt;const size_t R, const size_t C&gt; std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const Matrix&lt;R,C&gt;&amp; m) { for (size_t row=0; row&lt;R; ++row) { for (size_t col=0; col&lt;C; ++col) { std::cout &lt;&lt; m[row][col] &lt;&lt; '\t'; } std::cout &lt;&lt; std::endl; } return os; } int main() { std::default_random_engine generator; std::uniform_int_distribution&lt;int&gt; distribution (1,9); const size_t rows = 2; const size_t cols = 3; Matrix&lt;rows, cols&gt; a, b; for (size_t row=0; row&lt;rows; ++row) { for (size_t col=0; col&lt;cols; ++col) { a[row][col] = distribution (generator); b[row][col] = distribution (generator); } } std::cout &lt;&lt; "Matrix a:\n\n" &lt;&lt; a &lt;&lt; '\n' &lt;&lt; std::endl; std::cout &lt;&lt; "Matrix b:\n\n" &lt;&lt; b &lt;&lt; '\n' &lt;&lt; std::endl; std::cout &lt;&lt; "Matrix a + b:\n\n" &lt;&lt; a + b &lt;&lt; '\n' &lt;&lt; std::endl; std::cout &lt;&lt; "Matrix a - b:\n\n" &lt;&lt; a - b &lt;&lt; '\n' &lt;&lt; std::endl; Matrix&lt;cols, rows&gt; c; for (size_t row=0; row&lt;rows; ++row) { for (size_t col=0; col&lt;cols; ++col) { c[col][row] = distribution (generator); } } std::cout &lt;&lt; "Matrix c:\n\n" &lt;&lt; c &lt;&lt; '\n' &lt;&lt; std::endl; std::cout &lt;&lt; "Matrix a * c:\n\n" &lt;&lt; a * c &lt;&lt; '\n' &lt;&lt; std::endl; }


What is the Internal circuit diagram of crystal oscillator?

Ans. A series L R C in parallel with C' .


Why is the R-C oscillator also called a phase shift oscillator?

The R-C oscillator is also called a phase shift oscillator because the R-C filter creates a phase shift from input to output. The feedback portion of the oscillator (an amplifier) then serves to pump energy back into the filter.


What is the Algorithm for transpose of matrix in python?

Algorithm: transpose Input: a matrix M[x][y] Output: the transpose of M (a matrix of order y * x) allocate N[y][x] for r = 0 to x-1 // iterate over rows for c = 0 to y-1 // iterate over columns N[c][r] = M[r][c] next c next r return N


How to write a c plus plus program to multiply matrices using function template?

#include&lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;cassert&gt; unsigned multiply_recursive (unsigned a, unsigned b) { if (!a !b) return 0; // Note: not(a) or not (b) if (a==1) return b; if (b==1) return a; return a + multiply_recursive (a, --b); } unsigned multiply_iterative (unsigned a, unsigned b) { int product = 0; int x = std::min (a, b); int y = std::max (b, a); while (x--) product += y; return product; } int main() { unsigned x, y; // Test all combinations with 0. x = multiply_recursive (0, 0); assert (x==0); x = multiply_iterative (0, 0); assert (x==0); x = multiply_recursive (0, 1); assert (x==0); x = multiply_iterative (0, 1); assert (x==0); x = multiply_recursive (1, 0); assert (x==0); x = multiply_iterative (1, 0); assert (x==0); // Test non-zero values with 1. x = multiply_recursive (1, 42); // inefficient: lowest value must be on right (fewer recursions). y = multiply_iterative (1, 42); assert (x==42 &amp;&amp; y==42); x = multiply_recursive (42, 1); y = multiply_iterative (42, 1); assert (x==42 &amp;&amp; y==42); // Test other non-zero values are commutative. x = multiply_recursive (24, 42); // inefficient: lowest value must be on right (fewer recursions). y = multiply_iterative (24, 42); assert (x==1008 &amp;&amp; y==1008); x = multiply_recursive (42, 24); y = multiply_iterative (42, 24); assert (x==1008 &amp;&amp; y==1008); }

Related Questions

What does unconditional friendship mean?

that u r friends regardless no matter what happens


What has the author Geoffrey R Harris written?

Geoffrey R. Harris has written: 'Loops and unoriented strings'


What is p equals r-c for c?

p = r - c r - c = p r - c - r = p - r -(-c) = -(p) c = -p


Write a c program of matrix addition to handle two dimensional array?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int a[3][3],b[3][3],c[3][3],r,c; for(r=0;r&lt;=3;r++) { for(c=0;c&lt;3;c++) { printf("\n enter the value="); scanf("%d%d",&amp;a[r][c],&amp;b[r][c]); } } printf("\n first matrix=\n"); for(r=0;r&lt;=3;r++) { for(c=0;c&lt;3;c++) { printf("%d\t",a[r][c]); } printf("\n"); } printf("\n scond matrix=\n"); for(r=0;r&lt;=3;r++) { for(c=0;c&lt;3;c++) {printf("%d\t",b[r][c]); } printf("\n"); } printf("\n sum of given matrix=\n"); for(r=0;r&lt;=3;r++) { for(c=0;c&lt;3;c++) { c[r][c]=a[r][c]+b[r][c]; printf("%d\t",c[r][c]); } printf("\n"); } getch(); }


What is a romantic word that begins with the letter 'U'?

Nice words that start with R are:radiantraspberryrationalravishingrealisticreasonablerefinedreliableremarkableremembrancerespectfulresplendentresponsiblerhymeribbonsricerichesrighteousrobustromanticromprosemaryrosyruby


How do you use an array to show the commutative property?

If the array consists of r rows and c column, and the total number of cells in the array are n = r*c, then r*c = n and c*r = n so that r*c = c*r : which is commutativity of multiplication.


C equals 2pei R find for R?

Presumably C means circumference and R means radius? If C = 2*pi*R Then R = C divided by 2*pi


What is C equals 2r for r?

If: C = 2r Then: r = C/2


Why are raccoon enemies to bald eagles?

b/c they r!!!!!! b/c they r!!!!!! b/c they r!!!!!!


What is the letter of 3?

ab[C]defghijklmnopqrstuvwxyz. Exuse me but i think it is [R]. It is [C] or [R]. R is from th[r]ee. C is from [1 A] [2 B] [3 C]. ?


What is 27 c in r c?

presumably, r=27?


Formula of r form c equals 2pi r?

The circumference of a circle C is 2Pixr So solving for r we have C/2Pi=r