Concept explainers
What output is produced by the following code?
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Database Concepts (7th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- Given string inputString on one line, character userChar on a second line, and integer strIndex on a third line, output "Match found" if the character at index strindex of inputString matches userChar. Otherwise, output "Match not found". End with a newline. Ex: If the input is: write i 2 then the output is: Match found Note: Assume the length of string inputString is greater than strIndex. 1 import java.util.Scanner; 2 3 public class Matching Char { 4 5 7 8 9 10 11 12 13 14 15 16 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String inputString; char userChar; int strIndex; 3 inputString = scnr.nextLine(); userChar scnr.next().charAt(0); strIndex scnr.nextInt(); *Your code goes here */arrow_forward7. Given the following code, what initial values for num will cause an error during execution? int mystery(int num) { if (num 0) == return 0; else if (num 0 B. num > -100 and num < 0 C. num < 0 D. None of these will cause an error. 8. For the code in the previous problem, what will happen if the initial value of num is invalid?arrow_forward8. Find the output. b1 = True b2 = False b3 = False if b1 or b2 and b3: print ("Hello!") else: print ("User")arrow_forward
- Given int x = 6; double y = 3.14159265358979; String s = "pi"; which of the following generates the following string"pi = 3.142"arrow_forward3. int x =9 ;display the address of the variable x? Answer:arrow_forwardint x = 8, y = 3, z = 5; x += x + y * z + z * z; printf("%i\n", x); // what is the outputarrow_forward
- 01 / Select the correct answer: 1- What is the output of the following code? A = [2 4 3;5 7 1;2 4 1]; B = A(:,2:3) a- B = [4 3;7 1;4 1] b- B = [4 1;1 7;4 3] c- B = [5 7 1;2 4 1] d- B [2 4 3]arrow_forwardGiven string inputString on one line, character inputChar on a second line, and integer strIndex on a third line, output "Match found" if the character at index strIndex of inputString matches inputChar. Otherwise, output "Match not found". End with a newline. Ex: If the input is: warmth m 3 then the output is: Match found Note: Assume the length of string inputString is greater than strIndex. import java.util.Scanner; public class CharMatch {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);String inputString; char inputChar; int strIndex; inputString = scnr.nextLine(); inputChar = scnr.next().charAt(0); strIndex = scnr.nextInt();/* Your code goes here */}}arrow_forwardGiven integer variables seedVal, smallestValue, and largestValue, output three random integers in the range of smallestValue to largestValue inclusive. End each output with a newline. Ex: If smallestValue is 1 and largestValue is 94, then one possible output is: 82 75 72 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 789gum345613 10 11 int seedVal; int smallestValue; int largestValue; cin >> seedVal; cin >> smallestValue; 12 cin >> largestValue; srand (seedVal); * Your code goes here */ return 0; 2 3arrow_forward
- Given the snippet of code: int al = {2, 4, 6, 8, 10, 12), x, *p = a; x = *(p + 4)+1; printf("%d", x); What will be the value of x after the following statement is executed? 13 5 12 11arrow_forwardWhen the input integer variable numberOfBicycles is: • greater than or equal to 50, output "Too many bikes". between 19 inclusive and 50 exclusive, output "Large bike rack". • between 0 exclusive and 18 inclusive, output "Small bike rack". less than or equal to 0, output "Invalid number". ● End with a newline. ► Click here for examples 1 import java.util.Scanner; 3 public class Bicycle Details { L235N 4 6 7 public static void main(String[] args) { Scanner scnr = new Scanner (System.in); int numberOfBicycles; 8 9 numberOfBicycles = scnr.nextInt (); 10 /* Your code goes here */ 11 if(numberOfBicycles >=50) { 12 13 14 15 System.out.println("Too many bikes"); }else{arrow_forward12. Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment. function isEven(num){ if(MISSING CONDITION){ return true; } else { return false; A. num % 2 == 0; B. num % 0 == 2; C. num % 1 == 0; D. num % 1 == 2: Powered by Linklt! ооarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education