5.
double finalExam_Q1_5() {
int x,i;
x = 2;
for(i = 1;i<10;i++) {
if(!(i<=0 && i<=8))
i = 10;
if((i == 5) || (i== 7))
x = x+i;
if(i ==4)
x=-4;
}
return x;
}
//1. !is incorrect in if statement. The if condition must be inside
brackets if(condition)
//2. i = 10; instead of i == 10. = is used for assignment. == is
used for comparison
//3. || must be used as or instead of single |
//4. the conditions inside if must be inside brackets if((i == 5)
|| (i== 7))
//5. instead of x=-4, statement must be x-=4;
//6. (0>=i <=8 canbe written as if(!(i<=0 &&
i<=8))
6.
#include<stdio.h>
void main() {
char str[300] = "All Good";
// print string
printf("%s",str);
}
please solve 5 and 6 5. The following C function contains 6 syntax errors, identify them...
There are four syntax errors/incorrect statements in the following class definition. List the line numbers of the lines that contain errors, and then write the corrected line(s). (4 points) class jetType //Line 1 { //Line 2 public: //Line 3 void setValues(string, int, double); //Line 4 print() const; //Line 5 string getManufacturer() const; //Line 6 double getPrice() const; //Line 7 bool compareSeating(const jetType&); //Line 8 int jetType(); //Line 9 jetType(string); //Line 10 jetType(string, int, double); //Line 11 private; //Line 12 string...
1- Correct the syntax errors in the following program, and rewrite the program so that it follows the proper style conventions. What does the program do? (Write it out as a comment). (10 pts) #include <stdio.h> int main() {/* * Calculate and display the difference of two values *) int X, /* first input value */ x, /* second input value */ sum; /* sum of inputs */ X=9, x=7.5 X + x = sum; printf("%d + %d = %d\n";...
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...
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...
Please hlep as I've tried this C++ program and keep coming up with the wrong syntax somewhere. I need help defining the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in...
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...
Find the syntax error(s) in the following class and function definition. [You need to identify the line number only). 1. class Class1 2.{ 3. private 4. int data; 5. public 6. class1: class 1(); 7. double function 1(); 8.} 9. class: class 10) 10.{ 11. data =5; 12.}
CAN ANYONE PLEASE HELP ME SOLVE THIS PROBLEM WITHOUT RETURNING ERRORS, BAD TOKENS, ETC. PLEASE INCLUDE CORRECT SYNTAX...MUST BE IN PYTHON 3 AND PASS THE TEST Write a function analyze_text that receives a string as input. Your function should count the number of alphabetic characters (a through z, or A through Z) in the text and also keep track of how many are the letter 'e' (upper or lowercase). Your function should return an analysis of the text in the...
3. The short program below has one or more syntax, runtime, or semantic errors. Identify the errors and correct them. The number of errors to locate is identified. (Total = 8 pts) Consider a sequence of non-negative integers, where each number is written in a separate line. The sequence ends with 0. Find how many elements of this sequence are equal to its largest element. (4 errors) EXAMPLE LO: Input: Input: Output: Output: while True: a = input () if...
Please use C language with basic terms. Please fast, thank you so much :) Write a function declared as "int categorize(char *str)" which accepts a string as an input parameter and categorize the string. The function should return the category number as decribed below: Category 1: If the string contains only capital letters (e.g. ABCDEF), the function should return 1. Category 2: If the string contains only small letters (e.g. abcdef), the function should return 2. Category 3: If the...