Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Similar questions
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forwardC programmingarrow_forward#include using namespace std; int main() { } int kidsInClass1; int kidsInClass2; int numClasses; double kidsAvgMethodl; double kidsAvgMethod2; kidsInClass1= 3; kidsInClass2 = 2; numClasses = 2; Type the program's output kidsAvgMethodl = static_cast (kidsInClass1 + kidsInClass2) /static_cast (numClasses); kidsAvgMethod2 (kidsInClass1 + kidsInClass2) / numClasses; cout << kidsAvgMethod1 << endl; cout << kidsAvgMethod2 << endl; return 0; =arrow_forward
- Given C code: #include <stdio.h>typedef struct compound { float realNumber; float imaginaryNumber;} compound; compound add(compound n1, compound n2); int main() { compound n1, n2, temp; printf("For the first compound number \n"); printf("Enter the real and imaginary parts: "); scanf("%f %f", &n1.realNumber, &n1.imaginaryNumber); printf("\nFor the second compound number \n"); printf("Enter the real and imaginary parts: "); scanf("%f %f", &n2.realNumber, &n2.imaginaryNumber); temp = add(n1, n2); printf("Sum = %.1f + %.1fi", temp.realNumber, temp.imaginaryNumber); return 0;} compound add(compound n1, compound n2) { compound temp; temp.realNumber = n1.realNumber + n2.realNumber; temp.imaginaryNumber = n1.imaginaryNumber + n2.imaginaryNumber; return (temp);} Task: Please change the C program above to execute complicated numeral multiplication. Hint: (e+fi)(g+hi) = (eg−fh) + (eh+fg)iarrow_forwardFind the error(s), if any 1) void main(){int a = 15;float b = 10;char cha = 'a';char chb = 'b';do{a += b;a = a * b / 4;cout<<a<<b/a<<endlcout<<cha;for (int i=0; i<20; i++); {cout<<i;}}while(a=<1000)}; 2) The following code should output the even integers from 2 to 100:counter = 2;do{cout << counter << endl;counter += 2;} While ( counter < 100 );arrow_forwardWrite a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in reverse binary For an integer x, the algorithm is As long as x is greater than 0. Output x2 (remainder is either 0 or 1) *-*/2 Note: The above algorithm outputs the 0's and 1's in reverse order. Exif the input is 16 the output is 011arrow_forward
- debug the codearrow_forwardFind the error in the following code and explain how to fix it: #include int main(void) int *ptr; int m 100; ptr = m; printf("%d",*ptr);arrow_forwardMemory Management Programming Assignment Please if this can be coded in Java or C++ i would appreciate implement and test the GET-MEMORY algorithm This algorithm uses the Next-Fit(First-Fit-With-A-Roving-Pointer) technique. implement and test the FREE-MOMORY algorithm Implement the “GET_MEMORY” and “FREE_MEMORY” algorithms. Comprehensive testing must be done for each algorithm. Following are sample run results for each: GET_MEMORY IS RUNNING……… Initial FSB list FSB# Location Size 1 7 4 2 14 10 3 30 20 . . . . . . Rover is 14 ---------------------------------------------------------------------------- Allocation request for 5 words Allocation was successful Allocation was in location 14 FSB# Location Size 1 7 4 2 19 5 3 30 20 . . . . . . Rover is 30 ---------------------------------------------------------------------------- Allocation request for 150 words Allocation was not successful . . . __________________________________________________________ FREE_MEMORY…arrow_forward
arrow_back_ios
arrow_forward_ios