Please explain this question void main() {int a =300; char *ptr = (char*) &a ; ptr ++; *ptr =2; printf("%d", a); }
Q: #include using namespace std; void myfunction(int num2,int num1); int main(){ myfunction(5,2);…
A: Please find the answer below :
Q: (5) def add_chars (some_list, some_str): Special Restrictions: You are not allowed to use loops. You…
A: Define add_chars() function to add characters in the lists. Define add_chars_helper() inner…
Q: Find the error in the following code and explain how to fix it:
A: The error in the code is in the line : ptr=m; Because ptr is a pointer variable and we cannot assign…
Q: int sum (int a, int b) { return (a + b); } int main() { } Parameters int total; total = sum ( 10,…
A: Here we have given a clear explanation of the code given in C-Programming language. You can find the…
Q: 8.) #include int main() { } int a; char *x; x = (char*) &a; a = 512; x[0] = 1; x[1] =2;…
A: Given: Why does this C program produce a large endian output of 258 but a little endian output of…
Q: (a) #include using namespace std; int main() { } for (int i = 0; i <=30; cout << i*2 << endl; }…
A: In the given code: The loop will start from i=0 For i = 0 it will print 0*2 = 0 Now i has to be…
Q: Each of the following definitions and program segments has errors. Locate as many as you can and…
A: void showValues(int nums[ ]) *// Definition of the function showValues. { for (int…
Q: C language programming .
A: Required:
Q: Void Do1 (int: &, a. int &b) { a = 5; a = a + b; b = a + 2; } Int main() {…
A: We have given a C++ code and in which pass variable by reference. Here, integer variable x pass by…
Q: #include using namespace std; const int y = 1; int main () ( int static y - 2; int i = 3, j - 4, m…
A: The output along with the explanation is given below:
Q: 3.21 LAB: Smallest number Write a program whose inputs are three integers, and whose output is the…
A: Here is your solution -
Q: Fill in the blanks
A: Explanation: The correct code after filling up all the blanks in the code is given below. In the…
Q: int pertambahan(int pilihan, int now){ int result; result =pilihan + now; return result; } int…
A: Given Program: #include <stdio.h> int pertambahan(int pilihan, int now){ int result; result…
Q: Explain the values of int data type.
A: Integer data type: The Integer data type is used to store numeric value for variables. The Integer…
Step by step
Solved in 3 steps with 2 images
- #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…C programming#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; =
- 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)iFind 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 );Write 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 011
- debug the codeFind 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);Memory 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…