Given the following C++ code snippet, what is the value of result? Your answer must be exact. If there is an error, enter "error". const int size - 4; int my_num_arr[size] {10, 15, 6, 12}; int "my_ptr[size]; for(int i = e; i< size; i++) { 1| *my_ptr[i] - my_num_arr[i]; int result - *my_ptr[@] + my_num_arr[1]; cout <« result;
Q: Suppose you were given the following code segment: int a[5] = { 1, 2, 4, 8, 16 }; int *p = a; int…
A: Concept of array and pointer is being used here, I have defined everything in comments of code , and…
Q: 1. Write a readEmployee function that takes a pointer to an employee struct and fills in the…
A: #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int…
Q: Although it will no longer be used, please leave the earlier global variable with the initialized…
A: Clarification:-Here I have made the capacity named readEmployee(), inside the capacity I have taken…
Q: 1.) If the dimension for array temperature is 7 rows and 2 columns, how many instances the inner…
A: #include<iostream>#include<iomanip> using namespace std; int main(){ int temp [7][2];…
Q: What will happen in the following C code snippet? int a = 100, b = 200; int *p = &a, *q = &b; %3D…
A: The given code snippet is given by: int a=100,b=200;int *p=&a,*q=&b; p=q; The code snippet…
Q: Need help with it printing out d for some reason it is printing out all the other things I wanted to…
A: - We have to work to get the address of d.
Q: What is the output of the following C++ code? #include using namespace std; class A {…
A: In the given code class inherited the values from main class and in this declared one integer,…
Q: please help me with this c++ code, and I did not understand why the output is x=10 y=20. Please…
A: The above code is a simple example of chaining of function calls. The C++ code has used an object to…
Q: Although it will no longer be used, please leave the earlier global variable with the initialized…
A: Here I have created a function named readEmployee(). In this function, I have taken input from the…
Q: What is the scope of identifier x which is declared in Line 4? Consider the following program: const…
A: Scope of the variable: Local variable: Variables declared inside the function or block are called…
Q: Given the code below, assume that all the fork/pipe operations succeed, and neglect any syntax…
A: Answer is given below-
Q: I keep getting the error "undefined reference to 'main'". What am I doing wrong? Here is the code,…
A: #include <stdio.h>#include <stdlib.h>#include <string.h> int main(){char…
Q: The aim of this program is to ask for inputting the three sides of two triangles, constructs the two…
A: EXPLANATION: There is no parameterized constructor for the given class, and therfore when the…
Q: Consider this snippet of C code (which will not run as is because of the questions marks): char…
A: According to the information given:- We have to find out the replacement values of ? marks.
Q: Although it will no longer be used, please leave the earlier global variable with the initialized…
A: Memory Layout of C Programs A typical memory representation of a C program consists of the…
Q: What is the ouput of the following C code segmer void * T( void* me) { int s=0; for (int k=1; k<=me;…
A: It is defined as a powerful general-purpose programming language. It can be used to develop software…
Q: /I need help debugging the C code below the image is what I was following for directions while doing…
A: The Above Code is Debug Success full:
Q: Section 1: FIFO Page Replacement Algorithm In FIFO page replacement, the pages are simply placed in…
A: Start Declare the size to page length Check the need of replacement from the page to memory Check…
Q: Could you write this code in c language for me in the same way? #include #include using…
A: C Code :- #include<stdio.h> #define MAX 80int mat[MAX][MAX]; void fillRemaining(int i, int j,…
Q: Consider the definition of the class integerManipulation . What is the output of the following C++…
A: Explanation: In the given code, the function “classifyDigits()” is used to count the total number of…
Q: Part 1 Count the occurrences of a single character in a string. Example output: $ ./lab02 foobar o $…
A: The above code is wrong and has errors. The correct C program for the above problem is given in the…
Q: void my_func(int i, int& j) { int k; 6; k = i + i = i * 2; j = i + 3 + k; 1. What is the output of…
A: To invoke the given function definition in the program and to find the output
Q: What is the value of var after running the following piece of C code? int var-10; if (var10) var -…
A: Given code: int var =10; if(var<20) { var = var +5; if (var >10) { var = var +10; } else{…
Q: Consider the following C++ code; class rectangle { private: int length, width; public: rectangle()…
A: Which of the following is the correct declaration for friend function for the given c++ program? a.…
Q: C programming #include int main() { int i, j, n ; printf("height? ") ; scanf("%2d", &n) ; for (i =…
A: Answer: program 1:- #include <stdio.h> int main() { int i, j, n ; printf("height? ") ;…
Q: Please can you figure out the problem because it keeps say Invalid Credit when I chose 2?
A: Dear Student, You have written in if part that if(c!=15 && c!=30) { cout<<"Invalid…
Q: please fix what is wrong with the below C# code:
A: 1. In your code the checkGuess function should be separate from main function 2. Main function…
Q: Predict the output of the following program when the user enters 0, 1, and 2. #inçlude kiostream>…
A: GIVEN:
Q: he twins Kartik and Kunaal want to play word search puzzles with their class. They want to be faster…
A: • check all cells. If a cell has the first letter, we will then try all 8 directions one by one from…
Q: Please USE PYTHON Implement the design of the Pasta class so that the following output is…
A: 1) Below is python program to implement the design of the Pasta class so that the following output…
Q: Please make the modifications in "C programme" and try to complete all three parts kindly.…
A: Make the following modifications to the code Add a password-protected authorization system so that…
Q: The charge for all signs is a minimum of $35.00. The first five letters or numbers are included in…
A: Input count of characters, make and color and based on them add respective costs Print final cost
Q: Write a C++ program that breaks string s1 into "tokens" ( logical pieces such as words in a line of…
A: strstr() is the apparatus you are searching for. It can find a string inside another string.…
Q: #include #include using namespace std; class TotalResistance { double…
A: Comments are required to document program functionality. Comments may be inline as well and may be…
Q: Given the following C++ code const int size=5; int Num[size]; for (int i = 0; i < size; i++)…
A: Here we create a array of size 5 int Num[size]; Then this loop for(int i=0;i<size;i++)…
Q: //I need help debugging the C code below the image is what I was following for directions while…
A: SUMMARY: - Hence, we discussed all the points.
Q: This is part of my hangman simulation in C++. If you compile and run it and type "Easy," the code…
A: Answer:
Q: Write a program that computes the number of extraterrestrial civilizations capable of communicating…
A: Note :- You have not mention the language of the program so. i'm answering your question in C++…
Q: Consider the following code: Int a=5,b=a++ - 2; a)Explain what happened in above code?
A: The variable "a" is initialized with value "5", and the variable "b" is initialized with the value…
Q: need help debugging the C code below the image is what I was following for directions while doing…
A: // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); //…
Q: Write the output of the following C++ code? #include #include using namespace std; class A…
A: Que. Write the output of the following C++ code? Ans. Given, Programming language = C++ Code:…
Q: Consider the following C++ code and answer the questions: const int size=5; int Num[size]; for…
A: EXPLANATION - a) Value of *Num is 1 . A program is created . In main function the variable named…
Q: Your objective is to write to write a complete C++ that Prompt the user and store their inputs in…
A: Data types in C++ programming language: The data types are used to store the type of the values and…
Q: c++ program to find min and max
A: You can Use following code:- #include <iostream> using namespace std; void getMinMax(int…
Q: What is the scope of identifier Sum which is declared in Line 6? * Consider the following program:…
A: D) Line 6 to Line 9
Q: A programmer notices the following two procedures in a library. The procedures do similar, but not…
A: Procedure MaxFour (w,x,y,z) which returns the greatest of its four integer parameters is the…
Q: What is the output of the following C++ code? #include using namespace std; class A { public:…
A: Code: #include <iostream> using namespace std; class A { public: A(int n ) {…
Q: Remove error from given code and complete that programs by defining its main ()
A: The error + main() is written in BOLD LETTERS. --------------------------------------------------…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- The aim of this program is to ask for inputting the three sides of two triangles, constructs the two corresponding triangle objects in C++ using the class Triangle, compare the areas of these two triangle objects, and print whether or not the areas of these two objects are the same. Find the bugs in the code #include <iostream> using namespace std; class Triangle { int sideA, sideB, sideC; public: int area(); }; int Triangle::area() { return sideA * sideA * sideA; }; int main() { int a1 = 0, b1 =0, c1 =0, a2=0, b2=0, c2=0; cin >> a1 >> b1 >> c1; // for triangle one cin >> a2 >> b1 >> c2; // for triangle two Triangle t1(a1, b1, c1); Triangle t2(a2, b2, c2); if (t1.sideA == t2.sideA && t1.sideB == t2.sideB && t1.sideC == t2.sideC) cout << "same size" << endl; else cout << "different size" << endl; }I keep getting the error "undefined reference to 'main'". What am I doing wrong? Here is the code, it is in the language of C #include <stdio.h>#include <stdlib.h>#include <string.h> char *mult_digits (const int *digits, int n){ //impliment me char *product = (char *) malloc (sizeof (digits) * (n + 2)); char *productstring = (char *) malloc (sizeof (digits) * (n + 2)); int carry = 0; int previousnum = 1; int length; int k; int tempproduct; int tempremainder; for (length = length - 1; length >= 0; length--) { int tempnum = (digits[length]); tempproduct = (tempnum * previousnum) + carry; tempremainder = ((tempproduct) % 10); carry = ((tempproduct - tempremainder) / 10); previousnum = tempproduct; product[length] = (tempremainder) + '0'; } if (carry = 0) { for (k = 0; k <= strlen (product); k++) { productstring[0] = carry + '0'; productstring[k + 1] = product[k]; printf ("%s \n",…I have a running code of a dining philosophers problem but it has a logic problem where it loops right after it asks how many of the philosophers are hungry thus unable to calculate how exactly the philosophers are going to eat below is the code: #include <stdio.h>#include <stdlib.h>#include <conio.h>#include <math.h>#include <string.h> void one(void);void two(void);void exit();int tph, philname[20], howhung, hu[20], cho;//{}[] int main(void){ int i, status[10],philname[10],howhung; printf("\n\nDINING PHILOSOPHER PROBLEM"); printf("\nEnter the total no. of philosophers: "); scanf("%d",&i); for(i=0;i<tph;i++) { philname[i] = (i+1); status[i]=1; } printf("How many are hungry : "); scanf("%d", &howhung); if(howhung==tph) { printf("\nAll are hungry..\nDead lock stage will occur"); printf("\nExiting.."); } else {…
- Can someone help me to improve the following code in C and make it functional? #include <stdio.h>#include <stdlib.h> void printMaze(int maze[10][10], int posX, int posY){int i;int j;printf("\033[0;0H\033[2J");for (i = 0; i < 10; i++){for (j = 0; j < 10; j++){if (i == posX && j == posY)printf("? ");else{if (maze[i][j] == 0)printf(" _ ");elseprintf("? ");}}printf("\n");}} void solveMaze(int maze[10][10], int x, int y){printf("posX: %i, posY: %i\n", x, y);if (x == 9 && y == 9){printf("*********Resuelto*********\n");exit(0);}if (maze[x + 1][y] == 0)return solveMaze(maze, x += 1, y);if (maze[x][y + 1] == 0)return solveMaze(maze, x, y += 1);if (maze[x - 1][y] == 0){if (maze[x - 1][y + 1] == 0)return solveMaze(maze, x -= 1, y += 1);}} int main(void){int option = 0;int count = 0;int maze[10][10] = {{0,0,0,0,0,1,1,1,1,1}, {1,1,1,1,0,1,0,0,0,0}, {1,1,1,1,0,1,0,1,1,0}, {1,0,0,0,0,1,0,1,1,0}, {1,0,1,1,1,1,0,1,0,0}, {0,0,1,1,0,0,0,1,0,1}, {0,1,1,1,0,1,1,1,0,1},…Consider the definition of the class integerManipulation . What is the output of the following C++ code? integerManipulation number(3510862895423079232);number.classifyDigits();cout << number.getNum() << ": The number of digits---- "<< endl;cout << " Even: " << number.getEvensCount() << endl<< " Zeros: " << number.getZerosCount() << endl<< " Odd: " << number.getOddsCount() << endl;I wrote this c++ program to find min and max, but why does the program say it cannot find the min and max. WHere I got wrong? Please help me reivse my code. Thank you #include <iostream>using namespace std; int getmin(int number[], int size){ int min=number[0]; for (int i=1; i<size; i++) { if (number[i]<min) min=number[i]; } return min;}int getmax(int number[], int size){ int max=number[0]; for (int i=1; i<size; i++) { if (number[i]>max) max=number[i]; } return max;}void getminandmax(int number[], int size, int* min, int* max) { for (int i=1; i<size; i++) { if (number[i] > *max) *max=number[i]; if (number[i] < *min) *min=number[i]; } } int main(){ int number[5]={5, 4, -2, 29, 6}; int min=number[0]; int max=number[0]; getminandmax(number, 5, &min, &max); system("pause>0"); return 0; }
- CAN YOU CONVERT FROM C TO C++? #include <stdio.h>#include <stdlib.h>#include <time.h> int r_pc[3] = {0, 0, 0};int w_pc[3] = {0, 0}; int lock = 0;int rlock = 0;int wlock = 0; int AR = 0; int critical_readers = 0;int critical_writers = 0; int panic = 0; int testandset(int *lock){if (*lock == 1)return 1; else{*lock = 1; return 0; }}I am trying to write a program for a bowling score in C++ Here is what I have so far: #include <iostream> int main() { const int numFrames = 10; //The number of frames is 10 const int numThrows = 21; //The number of throws is 21 int throws[numThrows]; //Input for when the number of throws is <21 int frameScores[numFrames]; //Frame scores for the frames /*Computes a score for a different amount of throws in case the number of throws is less than 21 */ for (int i = 0; i < numThrows; ++i) { //std::cout << "Please enter score for throw: " << std::endl; std::cin >> throws[i]; } /* Calculates the bowling scores for the first 9 frames */ int throwIndex = 0; for (int frame = 0; frame < 9; ++frame) { int frameScore = throws[throwIndex]; if (frameScore == 10) { //For a strike frameScore += throws[throwIndex + 1] + throws[throwIndex + 2]; ++throwIndex; } else { frameScore += throws[throwIndex + 1]; if…What is the output of the following C++ code? (2, 3) Submit your answer to dropbox. inti=1; int num=2; while(i<5) { num-num*i; i=i+1; } cout<<"i="<<i<<"and num="<<num<<endl;
- In this lab, you complete a prewritten C++ program for a carpenter who creates personalized house signs. price of any sign a customer orders, based on the following facts: The charge for all signs is a minimum of $35.00. The first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. If the sign is made of oak, add $20.00. No charge is added for pine. Black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering.The twins Kartik and Kunaal want to play word search puzzles with their class. They want to befaster than everyone else in their class, so they decided to write a C code to help them find wordswith a click of a button. Little did they know, everyone in class decided to do this question. You are required to implement search2D function. void search2D(char word[], int wordSize, const int Size, char grid[Size][Size]); search2D receives the word to look for char word[], the size of the word int wordSize, sizeof the grid const int Size and the puzzle grid char grid[Size][Size]. The word size can bebetween 2 and 23. You are NOT required to check for the validity of the word size.search2D should look for the first letter in the word row by row. If it finds the first letter of the wordin the puzzle, it should look for the remaining of the word in the 8 directions from the south and goesclockwise, i.e. south, south-west, west, north-west, north, north-east, east and lastly…In the C++ code below, what is the explanation: - why there are 2 getlines in the string name? (what will happen if only one?) - since there is an if statement, why is there no else statement? #include <iostream> using namespace std; int main() { int n; // uer input cout << "Enter number of students: "; cin >> n; string gender[n], name[n]; // input for name and gender for (int i = 0; i < n; i++) { cout << "Enter gender of Student: "; cin >> gender[i]; cout << "Enter name of Student: "; getline(cin, name[i]); getline(cin, name[i]); } cout << "---------------------" << endl; cout << "List of Female Students" << endl; // printing female students for (int i = 0; i < n; i++) { if (gender[i] == "Female") cout << name[i] << endl; } cout << "List of Male Students" << endl;…