Problem 1 After the execution of the following program segment: #include int main(void) { } int i, j; for (i = 0; i < 7; ++i) { for (j = 0; j

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 15SA
icon
Related questions
Question

Answer the given question with a proper explanation and step-by-step solution.

In c, answer the following

Problem 1
After the execution of the following program segment:
#include <stdio.h>
int main(void)
{
}
int i, j;
for (i = 0; i < 7; ++i) {
for (j = 0; j <i; ++j)
printf("%4d", i * j);
printf("\n");
}
}
1. How many times does the first call to printf execute?
2. How many times does the second call to printf execute?
3. What is the last value displayed?
Problem 2
What are the values of x, y, and z after execution of this three-statement fragment?
#include <stdio.h>
int main(void)
{
int x=5, y=2, z=0;
x = y + 2;
y = 2 * 2 + 1;
z += x;
printf("\n\nThe value of n is %d"
"\nThe value of m is %d"
"\nThe value of p is %d", x,y,z);
Transcribed Image Text:Problem 1 After the execution of the following program segment: #include <stdio.h> int main(void) { } int i, j; for (i = 0; i < 7; ++i) { for (j = 0; j <i; ++j) printf("%4d", i * j); printf("\n"); } } 1. How many times does the first call to printf execute? 2. How many times does the second call to printf execute? 3. What is the last value displayed? Problem 2 What are the values of x, y, and z after execution of this three-statement fragment? #include <stdio.h> int main(void) { int x=5, y=2, z=0; x = y + 2; y = 2 * 2 + 1; z += x; printf("\n\nThe value of n is %d" "\nThe value of m is %d" "\nThe value of p is %d", x,y,z);
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr