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 program declares a and b as variables.
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's wrong with this code?
float q;int *p;q = 100.7;p = &q;
what 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<
Need help only with the highlighted part no need for help with the code the code is just for reference
#include <stdio.h>
int printBin(int value);
int main(){
int num=10;
int tobinary= printBin(num);
printf("The number %d converted to binary as %d",num,tobinary);
unsigned int x = 1;
char *ccc = (char*)&x;
if(*ccc){
printf("This is Little endian");
}
else{
printf("This is Big endian");
}
getchar();
return 0;
}
int printBin(int value)
{
if(value<2)
return value;
return printBin(value / 2) *10 + value % 2;
}
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
- Given the following code, what is the value of *p? int i;int *p;i = 5;p = &i;arrow_forward3) What is the output of the following code segment? Why? int value1 = 5, value2 = 15; int *p1, *p2; p1 = &value1; %3D p2 = &value2; *p1 = 10; %3D *p2 = *p1; %3D p1 = p2; *p1 = 20; %3Darrow_forwardNeed help only with the highlighted part no need for help with the code #include <stdio.h> int printBin(int value); int main(){ int num=10; int tobinary= printBin(num); printf("The number %d converted to binary as %d",num,tobinary); unsigned int x = 1; char *ccc = (char*)&x; if(*ccc){ printf("This is Little endian"); } else{ printf("This is Big endian"); } getchar(); return 0; } int printBin(int value) { if(value<2) return value; return printBin(value / 2) *10 + value % 2; }arrow_forward
- C - Right Facing Anglearrow_forward/*** Returns a lowercase version of a user-entered letter* @param kbd* @return lowercase version of user-entered letter*/public static char getNewGuess(Scanner kbd) { }arrow_forwarda) Trace this code segment #include int main(void) { char b='k'; char *x = &b; int m=20; int *z; printf("*x=%c\n",*x); z=&m; *z=*z+2; printf("m= %d\n", m); *x='P"; printf("b= %c\n", b); return 0; } *x=. m= b=arrow_forward
- num1 = int(input("Enter first value:"))num2 = int(input("Enter second value:"))num3 = int(input("Enter third value:")) # Type your code after this line. if (num1 >= num2) and (num1 >= num3):print("Enter first value:" "Enter second value:" "Enter third value:" 'Largest value is:' , num1 )elif (num2 >= num1) and (num2 >= num3):print("Enter first value:" "Enter second value:" "Enter third value:" 'Largest value is:' , num2 )elif (num3 >= num1) and (num3 >= num2):print("Enter first value:" "Enter second value:" "Enter third value:" 'Largest value is:' , num3 ) What is wrong with thisarrow_forwardnum1 = int(input("Enter first value:"))num2 = int(input("Enter second value:"))num3 = int(input("Enter third value:")) # Type your code after this line. if (num1>=num2)and(num1>=num3):print("Enter first value:" "Enter second value:" "Enter third value:" 'Largest value is:' , num1)elif (num2>=num1) and (num2>=num3):print("Enter first value:" "Enter second value:" "Enter third value:" 'Largest value is:' , num2) else:print("Enter first value:" "Enter second value:" "Enter third value:" 'Largest value is:' , num3) When i run it, it states enter first value, enter second value, and enter third value, twicearrow_forwardTrace the following code and give the output int a = 2; cout << a; while (a < 200) { a *= 2; cout << ", " << a; }arrow_forward
- What does this function using to? int max(int a , int b) if(a > b) return a; else return b; } returns the maximum of two integer numbers returns the minimum of two integer numbers returns the maximum of an floating point numbers returns the minimum of two floating point numbersarrow_forwarddef f(x: float) -> int: return int(x) def g(x: str) -> float: return float(x) y = f(g("3.14")) Select all of the following statements that are true: y's inferred data type is float O y 's inferred data type is str O y's inferred data type is int There is a type error in this program None of the above are truearrow_forwardThere are 5 mistakes in the code below, highlighted by the red tilde. Fix each mistake by rewriting the code to the right. Just rewrite the lines that are incorrect. Hint, you might have to change a line that doesn’t have a tilde.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,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr