0% found this document useful (0 votes)
98 views2 pages

Assignment 2

The document provides instructions for Assignment #2 of the Computer Science and Numerical Analysis CS-220 course for Spring 2012. It includes 6 problems dealing with flow charts, programming in C++, and correcting errors in code. Students are encouraged to discuss problems with others but must write their own solutions.

Uploaded by

Hamza Nadeem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views2 pages

Assignment 2

The document provides instructions for Assignment #2 of the Computer Science and Numerical Analysis CS-220 course for Spring 2012. It includes 6 problems dealing with flow charts, programming in C++, and correcting errors in code. Students are encouraged to discuss problems with others but must write their own solutions.

Uploaded by

Hamza Nadeem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Science and Numerical Analysis CS-220 Spring 2012

Due Date: 05/03/2012 Assignment # 2:

Note: You are encouraged to talk to other people about these problems, but please write up the solutions by yourself. Always explain the answer in your own words; do not copy text from the book, other books, Web sites, your friends homework, your friends homework.

1. Draw the flow chart of followings (a). Library Management System? (1) (b). N! (N Factorial) (1) 2. Write programs to do the following (a). Input an integer representing seconds from the user and convert it into hours, minutes, and seconds. Use / and %. (b). Assign the integer 12345 into a character variable. What warning does the compiler give you, and what is the output when you print the character? Why doesn't the same value print as a character and an integer? 3. What is the value assigned to v3 in the following program? #include <iostream.h> void main() { int v1=7, v2=5, v3=0; v3=v1* (v2=6); cout << v3 << endl; }

4. Why doesn't the following program compile? (Explain the error message) #include <iostream.h> void main() { int v1=7, v2=5, v3=0; v3=v1* (v2=6; cout << v3 << endl; }

5. What is the output of this program? Why? #include <iostream.h> void main() { int stop = 0; while (stop = 0) { int blah; cout << "Give a value " << endl; cin >> blah; if (blah > 17) stop = 1 } } 6. Correct the errors in the following program #include <iostream.h> void main() int sum= value=0; char stop = 'n'; cout << "Give an integer for n, the number of values you will input\n"; int n; cin >> n; for (int i = 0; i <=n && stop='n', i++) { cout << input integer (i+1) << endl; cin >> value; sum += value; cout << "The sum so far is " << sum<< " Do you want to stop now?(y/n)" << endl <<; cin >> stop; if (stop == 'n') then i = n; } cout << "The final sum is " << sum << endl;

You might also like