Consider each of the following code fragments below that could be part of a C++ program. Each fragment contains a call to a standard C/C++ library function. Answer each question in one of the following three ways: - If the code fragment contains a compile-time error, write the word error for the answer. - If the code fragment contains no compile-time errors and you can determine its output at compile-time, provide the fragment’s literal output. - If the code fragment contains no compile-time errors but you cannot determine its exact output at compile-time, provide one possible evaluation and write the word example for the answer and provide one possible literal output that the code fragment could produce. (a) std::cout << sqrt(4.5) << '\n'; (b) std::cout << sqrt(4.5, 3.1) << '\n'; (c) std::cout << rand(4) << '\n'; (d) double d = 16.0; std::cout << sqrt(d) << '\n';

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Consider each of the following code fragments below that could be part of a C++ program. Each fragment contains a call to a standard C/C++ library function. Answer each question in one of the following three ways:

- If the code fragment contains a compile-time error, write the word error for the answer.

- If the code fragment contains no compile-time errors and you can determine its output at compile-time, provide the fragment’s literal output.

- If the code fragment contains no compile-time errors but you cannot determine its exact output at compile-time, provide one possible evaluation and write the word example for the answer and provide one possible literal output that the code fragment could produce.

(a) std::cout << sqrt(4.5) << '\n';

(b) std::cout << sqrt(4.5, 3.1) << '\n';

(c) std::cout << rand(4) << '\n';

(d) double d = 16.0;

std::cout << sqrt(d) << '\n';

(e) std::cout << srand() << '\n';

(f) std::cout << rand() << '\n';

(g) int i = 16; std::cout << sqrt(i) << '\n';

(h) std::cout << srand(55) << '\n';

(i) std::cout << tolower('A') << '\n';

(j) std::cout << exp() << '\n';

(k) std::cout << sqrt() << '\n';

(l) std::cout << toupper('E') << '\n';

(m) std::cout << toupper('e') << '\n';

(n) std::cout << toupper("e") << '\n';

(o) std::cout << exp(4.5) << '\n';

(p) std::cout << toupper('h', 5) << '\n';

(q) std::cout << ispunct('!') << '\n';

(r) std::cout << tolower("F") << '\n';

(s) char ch = 'D'; std::cout << tolower(ch) << '\n';

(t) std::cout << exp(4.5, 3) << '\n';

(u) std::cout << toupper('7') << '\n';

(v) double a = 5, b = 3; std::cout << exp(a, b) << '\n';

(w) std::cout << exp(3, 5, 2) << '\n';

(x) std::cout << tolower(70) << '\n';

(y) double a = 5; std::cout << exp(a, 3) << '\n';

(z) double a = 5; std::cout << exp(3, a) << '\n';

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY