Find the errors (both logic and syntax) in these segments of code and rewrite the entire code shown with the corrections. Assume that all headers and directives are included. Note that some problems contain multiple errors, and not only syntax errors. If there are no errors, write ”No Errors.”
1. (2 points) Test if x is divisible by 3.
int x;
cin << x;
if (!(x/3)) cout<< "x is divisible by 3";
can you solve this for c++? thanks
there are syntax errors in this program so please use the below program:
program:
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if ((x%3==0)) cout<< "x is divisible
by 3";
return 0;
}
Find the errors (both logic and syntax) in these segments of code and rewrite the entire...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // DebugFive2.java // Decides if two numbers are evenly divisible import java.util.Scanner; public class DebugFive2 { public static void main(String args[]) { int num; int num2; Scanner input = new Scanner(System.in); System.out.print("Enter a number "); num = input.nextInteger() System.out.print("Enter another number ");...
Debugging: The code below has six errors. The errors may be syntax errors or logic errors, and there may be more than one per line; examine the code carefully to find them. Indicate each of the errors you find by writing the line number and correction in the space provided below. This program is designed to take a constant number of scores (3 in this case) and store them into an array. Then the array is passed to a function...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. public class DebugTwo1 { public static void main(String[] args) { integer oneInt = 315; double oneDouble = 12.4; character oneChar = 'A'; System.out.print("The int is "); System.out.println(oneint); System.out.print("The double is "); System.out.println(onDouble); System.out.print("The char is "); System.out.println(oneChar); } }
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // Start with a penny // double it every day // how much do you have in a 30-day month? public class DebugSix1 { public static void main(String args[]) { final int DAYS = 30; double money = 0.01; int day =...
Please use Python3. Thanks Find and fix the errors (syntax or logic) in the following code snippet: # this function creates a 2D list using the height, width, and symbol. It does # not contain any shallow copies of rows def createList(height, width, symbol): board = [] for i in range(len(height)): row = [] for j in range(width): row.append(symbol) board.append(row) def main(): # creates 5 rows of 5 @s myList = createList(5,"@") print(board) main()
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // Prompt user for value to start // Value must be between 1 and 20 inclusive // At command line, count down to blastoff // With a brief pause between each displayed value import java.util.*; public class DebugSix3 { public static void...
The files provided contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. import java.util.*; public class DebugEight1 { public static void main(String args[]) { Scanner input = new Scanner(System.in); char userCode; String entry, message; boolean found = false; char[] okayCodes = {'A''C''T''H'}; StringBuffer prompt = new StringBuffer("Enter shipping code for this delivery\nValid codes are: "); for(int x = 0; x <...
C++ question The code below has five errors. The errors may be syntax errors or logic errors, and there may be more than one per line; examine the code carefully to find them. Indicate each of the errors you find by writing the line number and correction in the space provided below. You must find and correct all five of the errors. If there were no errors, this code would output: Paycheck for 123-45-678 : $690.625 Paycheck for 876-54-321 : $818.125 1...
12) 8 pts. Find the errors in the following code fragment and correct them. #i nclude <iostream> using namespace std; double fudge (double s) f return s 2.3; int mainO cout >> "Your original estimate" double estimate; cin >> estimate; cout << endl; for (int 1 = 0;1c3;i++); cout << "EStimate' < fudge(estimate) <<endl Hint: There are 4 syntax errors. There is one error that is syntactically correct but causes the output to not be what you would expect. Once...
What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice) 1. int laps = 8; if (laps++ > --laps) laps += 2; else if (--laps > (laps - 1)) laps += 4; else if (++laps) laps -= 3; cout << laps << endl; 2. What is the output of the following code snippet? int j = 47; int i = 8; j =...