Computer Science: A Structured Programming Approach Using C, Third Edition
3rd Edition
ISBN: 9780534491321
Author: Behrouz A. Forouzan, Richard F. Gilberg
Publisher: Course Technology, Inc.
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 25PS
Explanation of Solution
Given: The following code is given:
int a;
int b;
a = b = 50;
printf("%4d %4d",a,b);
a = a *2;
b = b / 2;
printf("%4d %4d", a, b);Â
To Find:Â The output of the following code.
int a;
int b;
a = b = 50;
printf("%4d %4d",a,b);
a = a *2;
b = b / 2;
printf("%4d %4d", a, b);Â Â
Solution:
The following code on being run will display the following output.
50 50 100 25
The
The reserved word, int, indicates a and b with integer values stored in the computer.
In the second step, the program store the values of a and b, that is, 50...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is the output of the following code segment?
int n = 1;do {
cout << n << ' '; n++;
} while (n >= 5)
What is the output of the following code segment?
int n = 1;do {
cout << n << ' '; n++;
} while (n <= 5);
Question 5
What is the output of the following code segment?
int num
cin>>x;
= 20, 5, X;
if (x >= 2*num)
y+=1;
else if (x >= num)
y+=2; if (x
What will be printed out as a result of the following code?int x = 5, y = 7;System.out.println(++x);x += y++;System.out.println(x + "," + y);
a.
66,8
b.
613,8
c.
513,8
d.
512,7
Chapter 3 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
Ch. 3 - A unary expression consists of only one operand...Ch. 3 - The left operand in an assignment expression must...Ch. 3 - Associativity is used to determine which of...Ch. 3 - Side effect is an action that results from the...Ch. 3 - Prob. 5PSCh. 3 - Prob. 6PSCh. 3 - Prob. 7PSCh. 3 - Prob. 8PSCh. 3 - Prob. 9PSCh. 3 - Prob. 10PS
Ch. 3 - Which of the following statements about mixed...Ch. 3 - Which of the following statements about compound...Ch. 3 - Prob. 13PSCh. 3 - Prob. 14PSCh. 3 - Which of the following is not a binary expression?...Ch. 3 - Prob. 16PSCh. 3 - If originally x=4, what is the value of x after...Ch. 3 - Prob. 18PSCh. 3 - Prob. 19PSCh. 3 - What is the value of each of the following...Ch. 3 - Given the following definitions, which of the...Ch. 3 - If originally x=2,y=3,andz=2, what is the value of...Ch. 3 - Prob. 23PSCh. 3 - If x=2945, what is the value of each of the...Ch. 3 - Prob. 25PSCh. 3 - Prob. 26PSCh. 3 - Write a program that reads two integers from the...Ch. 3 - Write a program that extracts and prints the...Ch. 3 - Prob. 29PSCh. 3 - Write a program that calculates the area and...Ch. 3 - Prob. 31PSCh. 3 - Prob. 32PSCh. 3 - Write a program that changes a temperature reading...Ch. 3 - Write the C code for each of the following...Ch. 3 - Prob. 35PSCh. 3 - Write a program that converts and prints a...Ch. 3 - Prob. 37PSCh. 3 - Write a program that prompts a user for an integer...Ch. 3 - Prob. 39PS
Knowledge Booster
Similar questions
- What is the output of the following code? def f(a, b): print b f(1, 3)arrow_forwardWhat will be the output?int a = 4, b =7, c; c = a == b; print("%d",c);arrow_forwardwhat is the output of the following code? #include int main() { int x = 23; double y = 11; printf("%lu", sizeof(x+y)); return 0}arrow_forward
- What is the output of the following code snippet?int main(){int num1 = 10;int num2 = 5;int num3 = 200;num3 = num3 % (num1 * num2);cout << num3 << endl;return 0;}a) 0b) 4c) 10d) There will be no output due to a run-time error.arrow_forwardWhat is the output of the following code segment? int num= 20, y = 5, x; cin>>X; if (x >= 2*num) y+=1; else if (x >= num) y+=2; if (xarrow_forwardWhat is the output of the following code? int num = 12;while (num >= 0){if (num % 5 == 0){num++;continue;}cout << num << " ";num = num - 2;}cout << endl;arrow_forward
- What is the printout of the following code? int[][] numbers = {{1}, {1, 2}, {1, 2, 3}};System.out.print(numbers.length + ", " + numbers[1].length); A. 3, 1 B. 1, 3 C. 3, 3 D. 3, 2arrow_forwardSuppose you were given the following code segment: int a[5] = { 1, 2, 4, 8, 16 };int *p = a;int *q = &a[3]; What is the printout of the following statement: cout << *(p + 1); A. 2 B. 3 C. 6 D. 7arrow_forwardwhat is the output of the following code segment? int x = 350; int y = 0; do { y +=x 0; X = x/10; } while (x!=0); cout<arrow_forward
- what will be the output? #include int main () {int i = 3; i++; print ("%d", i); i--; print ("%d", i); return 0;} a. 34, b. 33, c. 44, d. 43arrow_forwardWhat is the value of f(2) and f(4) after execution the following code in static mode:int f (int x) {static int a = 0;a +=2;printf(" %d/n",a );} f(2)?? f(4)??arrow_forwardwhat will be the output of the following code? #include <stdio.h> int main (void) { int a=3; int b=4; static int result = 1; result = a*b+a/3+b*2; print f("%d",result); return 0; }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,