questions 1 - Fundamentals Programming Laboratory 1 1 What...

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

View Full Document Right Arrow Icon
Fundamentals Programming Laboratory 1 1. What output would you expect from the following programs? #include <iostream> using namespace std; int main () { // Local ariable declaration: int x, y = 10; if(y < 10){ x = 30; } else{ x = 40; } cout << "value of x: " << x << endl; #include <iostream> using namespace std; int main () { // Local variable declaration: int x, y = 10; x = (y < 10) ? 30 : 40; cout << "value of x: " << x << endl; return 0; } 2. What does the following program do? That is, if you were to run the program, exactly what would the output be? #include <iostream> using namespace std; int main () { const int c1 = 3; const float c2 = 2.75; int j, k, n, m; float y; // n = 3.25; // statement 1 n = n + 2.5 * c1 + c2; // statement 2 m = 3.75 + n/c1; // statement 3 j = n % m; // statement 4 k = m % n; // statement 5 if ( j != k ) y = j + c2; // statement 6 else y = k – c2; // statement 7 cout << “The value of j = “ << j << endl; // statement 8 cout << “The value of k = “ << k << endl; // statement 9 cout << “The value of m = “ << m << endl; // statement 10 cout << “The value of n = “ << n << endl; // statement 11 cout << “The value of y = “ << y << endl; // statement 12 return 0; } Barbara Fryc
Image of page 1

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

View Full Document Right Arrow Icon
Fundamentals Programming Laboratory 1 3.
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern