Www.solomonlrussell.com
CS1 Midterm 1 Study GuideGo over all examples from class and homework.What value will z have if we execute the following assignment statement?double z = 10 / 40;What value will z have if we execute the following assignment statement?int z = 50 / 10.00;What will be the result of the following assignment statement? Assume b = 6 and c = -10. int a = b * (-c + 2) / 2;Know the differences between compile and run-time errors and be able to identify them in code. Understand when and why you have to use cin.ignore(...). Why are constants like const double TAXRATE = .1;important? Why do we use constants instead of variables? Consider the following code that will assign a letter grade of ‘A’, ‘B’, ‘C’, ‘D’, or ‘F’ depending on a student’s test score. Will it work correctly? If not, for what values of score will it work correctly? if(score >= 90)grade = 'A';if(score >= 80)grade = 'B';if(score >= 70)grade = 'C';if(score >= 60)grade = 'D';else grade = ‘F’;Assume month has been previously declared as an int and given a meaningful value. Write a switch statement that for any value of month, produces exactly the same output as the following if statement. if (month == 6)cout << "summer solstice";else if (month == 12)cout << "winter solstice";else if (month == 3 || month == 9)cout << "equinox";elsecout << "nothing special"; What is the output produced by the following program segment?string grendel = "endl";cout << "endl";cout << grendel;cout << endl;cout << "grendel";If x is currently 0, a = 5 and b = 5, what will x become after the statement below is executedif (a > 0)if (b < 0)x = x + 5;elseif (a > 5)x = x + 4;elsex = x + 3;elsex = x + 2;What is the output?int sum = 0;for (int k=0; k<5; k++) {sum += k;}cout << sum;What is the output?int z=2, sum=0;while(z<9){z++;sum=sum+z;}cout << sum;What is the output if the initial value of k and p are both 0?do {if(k= =1){ p+=3;} k++; p--;} while(k<3);cout << p ;What is the final value of p?double p = 0;for (int m=10; m>6; m--) {if (m==7) {p = p+m;}else {p++;}}What is the value of n after the following nested loops?int n = 0;for (int i = 1; i <= 5; i++)for (int j = 0; j < i; j++)n = n + j;Consider the following code segment, what is output?for (int i = 0; i < 5; i++) {for (j = i; j < 5; j++)cout << i;cout << endl;}Free Response:You and your date are trying to get a table at a restaurant. You and your date have stylishness of your clothes, in the range 0...10, If either of you is very stylish, 8 or more, then the result is "yes". With the exception that if either of you has style of 2 or less, then the result is "no". Otherwise the result is "maybe"The squirrels in Torrance spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a bool isSummer, output "Let's Play" if the squirrels play and "I'm tired" binatorics is the art of enumerating combinations and permutations. Write code (not the whole program) that will print all the triples of nonnegative integers that add up to the number 7. When the program is executed the output appears as something similar to: (Hint: I’d use 3 for loops arranged in a special way, it can also be done with 2)0 0 70 1 60 2 50 3 40 4 3.....6 0 16 1 07 0 0Write the code below to complete the program#include <iostream>using namespace std;const int SECS_PER_MIN = 60;const int SECS_PER_HOUR = 3600;int main(){int seconds, minutes, hours, secs_left, mins_left;cout << "Enter number of seconds: ";cin >> seconds;// your code goes HERE// do some calculations using modulus and// the division operatorcout << seconds << " seconds is equal to "<< hours << " hours, " <<mins_left<<" minutes, " << secs_left << " seconds" <<endl;return 0;}Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, ...6=Sat, and a boolean indicating if we are on vacation, print a string of the form "7:00am" indicating when the alarm clock should ring. Weekdays, the alarm should be "7:00am" and on the weekend it should be "10:00am". Unless we are on vacation -- then on weekdays it should be "10:00am" and weekends it should be "off".day: 1, vacation: false → "7:00am" day: 5, vacation: false → "7:00am" day: 0, vacation: false → "10:00am"You have a red lottery ticket showing ints a, b, and c, each of which is 0, 1, or 2. If they are all the value 2, print 10. Otherwise if they are all the same, the print 5. Otherwise so long as both b and c are different from a, print 1. Otherwise the result is 0.a: 2, b: 2, c: 2 → "10" a: 2, b: 2, c: 1 → "0" a: 0, b: 0, c: 0 → "5"Your cell phone rings. Print "Answer it!" if you should answer it and "Don't answer it!". Normally you answer, except in the morning you only answer if it is your mom calling. In all cases, if you are asleep, you do not answer.isMorning: false, isMom: false, isAsleep: false → "Answer it!" isMorning: false, isMom: false, isAsleep: true → "Don't answer it!"isMorning: true, isMom: false, isAsleep: false → "Don't answer it!" ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- george gamow memorial tournament round 5
- an english teacher s toolkit spirit of english
- prince of persia the sands of time the cia
- beowulf notes more
- okaloosa county school district
- this document is used in the pre ap ap classroom
- the contents of this article were produced by federal
- tic tac toe menu
- fiction for ages 13 and older on talking book word 200kb
- the annotated pratchett file v7a l space
Related searches
- getroman com reviews
- acurafinancialservices.com account management
- https www municipalonlinepayments
- acurafinancialservices.com account ma
- getroman.com tv
- http cashier.95516.com bing
- http cashier.95516.com bingprivacy notice.pdf
- connected mcgraw hill com lausd
- education.com games play
- rushmorelm.com one time payment
- autotrader.com used cars
- b com 2nd year syllabus