Question

7.) (3) Specify whether each of the following errors is a syntax error, a runtime error or a logic error a. using single quotes where command needs double quotes b. dollar and cents amount on a bill is not formatted correctly c.divide a number by zero 8.) (8) Evaluate the following expressions: a. fabs(-25.2) b. pow(4.0,3.0) c. sqrt(400) d. fabs(8.2) e.sqrt(-400) f. floor(-6.7) 9. floor(6.7) h. ceil(-4.1) 9.) (4) Indicate which of the following assignment statements are legal if x is an int variable and y is a float variable: a, y = x; b, x = y; c, y = (float) x; d, x = (int) y;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer-

7 a] syntax error // used the wrong predefined directive for the programming language

b] logical error // wrong formatting of dollars and cents results in faulty calculations

c] runtime error //can be seen during runtime

8] a] 25.2

b] 64

c] 20

d] 8.2

e] domain error occaurs

f] -7

g] 6

h] -4

9. a] This is legal

b] This is legal but the decimal part is truncated which results in loss of precision.

c] This is legal and the float variable gets the intger data stored in it.

d] This is legal but the decimal part is truncated which results in loss of precision.

Add a comment
Know the answer?
Add Answer to:
Specify whether each of the following errors is a syntax error, a runtime error or a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Find and name [syntax, runtime, semantic) all FIFTEEN Errors. (15 pts - finding, 15 pts...

    1. Find and name [syntax, runtime, semantic) all FIFTEEN Errors. (15 pts - finding, 15 pts - labeling) If more than 15 errors are found; 1 point bonus per extra, labeled error found. You can use the working assumption that the docstring is correct and the program should follow it exactly *The code is on the next page, and a section to list out line numbers and error type are on the page following that 1 def grocery_checkout(fruits, veggies, meat):...

  • ​​​​​​ 11.   A _____________ error does not cause the compiler to generate an error, but does...

    ​​​​​​ 11.   A _____________ error does not cause the compiler to generate an error, but does cause the program to produce incorrect results. Syntax, logic, variable name, function name 12.   A syntax error occurs when the programmer violates one or more grammar rules of the C language. True or False 13.   Given this line of code: y = sqrt(x); x would be known as the argument. True or False 14.   A void function does not return a value to the...

  • QUESTION 1 Which of the following Python variable names has syntax error ? OA. A. CSC121...

    QUESTION 1 Which of the following Python variable names has syntax error ? OA. A. CSC121 OB. B. CSC121 Oc. C. CSC-121 D. None of the above QUESTION 2 What data type will Python use to store the value of num_students ? num_students = 17.0 A. floating point number (i.e. float) OB. B. integer (i.e. int) Oc. string (i.e. str) Od. D. None of the above

  • Find the error in each of the following c++ program segments and explain how the error...

    Find the error in each of the following c++ program segments and explain how the error can be corrected. And rewrite the program appropriately using c++ a. int g(void){ cout<<”Inside function g”<<endl; int h(void) {             cout<<”Inside function h”<<endl; }                         } int sum(int x, int y){ int result; result = x+y;                         } void f(double a); {             float a;             cout<<a<<endl; }

  • answer two question,each question has 3syntax errors,find it. 1(a) The following segment of code contains at...

    answer two question,each question has 3syntax errors,find it. 1(a) The following segment of code contains at least three (3) syntax errors that will compilation to fail with errors. Identify each of these errors and specify the solution. [2 marks each, 6 marks in total] cause #include <stdio.h> void main (void) float height; float area; printf "input height of the rectangle: ") scanf( "%f", &height) printf"input length of the rectangle: scanf"", &length); height length; area printf( area of rectangle %f high...

  • The following file has syntax and/or logical errors. In each case, determine the problem, and fix...

    The following file has syntax and/or logical errors. In each case, determine the problem, and fix the program. using System; using static System.Console; using System.IO; class DebugFourteen1 { static void Main() { string fileName; string directory; string path; string files; int x; Write("Enter a directory: "); directory = ReadLine(); if(Directory.Exists(Directory)) { files = Directory.GetFiles(directory); if(files.Length = 0) WriteLine("There are no files in " + directory); else { WriteLine(directory + " contains the following files"); for(x = 0; x <= files.Length;...

  • 31. True or False: The condition in the following if statement is a syntax error:

     31. True or False: The condition in the following if statement is a syntax error: int number=50;…… if (number)…… 32. True or False: The standard C functlon strlen) will return 4 when invoked upon the varlable name, declared below: char namel = (e', 'p', 't', 's', '\0', '1', '2', '1', '\0']; 33. True or False: A structure is a collection of related variables under one name. 34. True or False: In C, output parameters allow for a function to return more than one value Indirectly. 35. True or...

  • 1,4,5 Multiple Choice (Find Output or Fix Error) 1. What will be the final value of...

    1,4,5 Multiple Choice (Find Output or Fix Error) 1. What will be the final value of product 7、 inta,b; Given above code, what will be the value of a andb if user types: 31 42 nt producr- 3, product 3 prodct while (product70) a) 81 31 What is the output of the following code? char Grade8 27 8. d) Error in do-while code 2. This loop is a good choice when you know how many times you want the loop...

  • Please help to resolve my error. This Java code is supposed to evaluate one line equation...

    Please help to resolve my error. This Java code is supposed to evaluate one line equation of the form X Operator =Z where X is any name of a variable and Y and Z are integers By user in equation solver window. Currently the code executes expressions such as Y Operator(+,-,*,/) Z package Equations; /** * This program evaluates arithmetic expressions */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.StringTokenizer; public class EquationSolver extends JFrame implements ActionListener { private JTextField...

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT