homework2-Godara

homework2-Godara - x = ( ( 5/2 ) * ( 813978 % 13 ) ) / 2;...

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

View Full Document Right Arrow Icon
Tanuj Godara 9052-79307 In-Lab Questions Number 1 #include <iostream> using std::cout; int main() { int x; //introduces a new integer x int y = 9; //introduces an integer y, which represents the number 9 double a = 4.7; //introduces a double, which can have decimal places. cout << a << "\n" ; //outputs "a," and then makes a new line. cout << (x = y) //sets x equal to y, and then skips two lines. << "\n\n" ; return 2; //returns it to the function } Number Two #include <iostream> using namespace std; int main() { const int a = 1024 ; char arr[a] = { 'p' , 'd' , 'j' , 'q' , 'h' , 'w' , 'l' , 'f' , '#' , 'i' , 'l' , 'h' , 'o' , 'g' , '#' , 'g' , 'h' , 'w' , 'h' , 'f' , 'w' , 'h' , 'g' , '1' , '\0' }; for ( int a = 0; a <24; a++){ arr[a] = arr[a] - 3; } cout << arr << endl; return 0; } THE MESSAGE IS “magnetic field detected.” Number Three #include <iostream> 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
int main() { double x;
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x = ( ( 5/2 ) * ( 813978 % 13 ) ) / 2; cout &lt;&lt; &quot;The output is : &quot; &lt;&lt; x &lt;&lt; endl; return 0; } THE NUMBER OUTPUT IS 9 Number Four #include &lt;iostream&gt; using namespace std; void main() { cout &lt;&lt; &quot;answer1 is the integer &quot; &lt;&lt; 9 / 4 &lt;&lt; endl; cout &lt;&lt; answer2 is the integer &quot; &lt;&lt; 17 / 3 &lt;&lt; endl; } THE NUMBER OUTPUTS ARE 2 AND 5 Number Five #include &lt;iostream&gt; using namespace std; void main() { cout &lt;&lt; &quot;The remainder of 9 divided by 4 is &quot; &lt;&lt; 9 % 4 &lt;&lt; endl; cout &lt;&lt; &quot;The remainder of 17 divided by 3 is &quot; &lt;&lt; 17 % 3 &lt;&lt; endl; } THE NUMBER OUTPUTS ARE 1 AND 2 Number Six #include &lt;iostream&gt; using namespace std; void main() { int num1, num2, num3; double amps1, amps2, amps3; double volts1, volts2, volts3; char codeA, codeB, codeC, codeD; }...
View Full Document

Page1 / 3

homework2-Godara - x = ( ( 5/2 ) * ( 813978 % 13 ) ) / 2;...

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

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