What's wrong? for (int k =2, k<=12, k++) the increment should always be ++k B the commas should be semicolons the variable must always be the letter i when using a for loop there should be a semicolon at the end of the statement
Q: Implement programs involving the use of while, do..while and for loop statement. Objectives: Topics…
A: Step-1: Start Step-2: Declare variables n, i, j, k Step-3: Take input number of rows n Step-4: Start…
Q: Complete the following for loop. The loop should display the numbers from 0 to 9 and from 0 to -9.…
A: #include<iostream> using namespace std; int main() { for(int i=0,j=0;i<10,j>-10;i++,j--)…
Q: The following while loop should print the sum of the integers between 0 and 5, inclusive. int sum =…
A: Given the following while loop should print the sum of the integers between 0 and 5. We have to find…
Q: 04: (A) what is the number of iterations in the following for loop? cin>>n; for (int i 1; i< n;…
A: Based on the 'n' value given by the user As i=1 I.e, from 1 to i<n i.e, upto i=n-1 From…
Q: Write a for loop that does exactly the same thing as the following code: j = 1; while (j < 13) {…
A: For loop equivalent of above while loop .Using C++ code
Q: The intention of the following program fragment is to print the positive integers from a through b,…
A: User has to enter starting number a and ending number b and program print number from a to b
Q: Convert the following while loop to a do-while loop: int x = 1; while (x > 0) { cout > x; }
A: Syntax of do while: do{ //code }while(condition);
Q: Can you always convert any while loop into a for loop? Convert the followingwhile loop into a for…
A: Given: Can you always convert any while loop into a for loop? Convert the followingwhile loop into a…
Q: Rewrite the following code, converting the while loop to a do-while loop: char doAgain = 'y';int sum…
A: Given: Rewrite the following code, converting the while loop to a do-while loop: char doAgain =…
Q: Input A line containing an integer. 214 Output Multiple lines containing an integer. 4 1 2
A: I have provided C++ CODE along with CODE SCREENSHOT and 2 OUTPUT…
Q: What's wrong? for (int k = 2; k>1; k++) A. There should be a semicolon at the end of the statement…
A: Answer is C:
Q: Convert the following for loop statement to a while loop and to a dowhile loop:long sum = 0; for…
A: long sum = 0; for (int i = 0; i <= 1000; i++) sum = sum + i; In while loop: long sum=0; int…
Q: Use a while loop (or do-while) to process the following for at least five employees: Ask the user…
A: Given:
Q: how to make the getline(cin>>was,full name) function to show when I am trying to make it show in a…
A: By using cin.sync() and cin.ignore() before reading full_name solves the issue. cin.sync() and…
Q: Convert the following while loop to a for loop: int count = 0;while (count < 50) {cout <<…
A: PROGRAM CODE: #include <iostream>using namespace std; int main(){ int count = 0;…
Q: Fill in the blank - here are your choices for the following question (not all of these answers will…
A: Below is the answer to above question. I hope this will be helpful for you..
Q: (A) what is the number of iterations in the following for loop? #include void main() { int n;…
A: Given code is #include<iostream.h> void main() { int n; cin>>n; for (int i=1;i<n;…
Q: Convert the following for loop statement to a while loop and to a do-while loop: long sum = 0;for…
A: In the body of the loop the statement is not clear. I am considering it as sum = sum + i; but not…
Q: What is the result for the code below? * disp('') disp(' While- loop Example '); disp(' ***** a = 0;…
A: In this question, we are given a MATLAB code and asked the output/result of the code. This code…
Q: Convert the following code into a while loop. i = 1; for (i<10;i+=5) printf("the prize.");…
A: Here this for loop run until i is less than 10. each time it run it will print printf("the prize.");…
Q: he following code isn't working correctly and I am unable to figure out why. The for loop is never…
A: srandom((unsigned)time(NULL) + my_rank);value = random() % 10;if (my_rank % divisor ==…
Q: Complete the following program that reads the beginning and the end of a for loop from the user and…
A: C++ Program: #include <iostream>using namespace std; // Function to print the number of odd…
Q: write a for loop that displays each integer number from 14 to 25 (inclusive) . include any necessary…
A: Step 1: Start. Step 2: Initialize variable Step 3: Check FOR condition. Step 4: If the condition is…
Q: Complete the following nested for loop. The loop should display the result of i times j. i should be…
A: As there is no language mentioned above, I am using c++ to develop the code. Code…
Q: Write the following for loop as a while loop. for (int count = 1; count <= 10; count++) cout…
A: Syntax: while(Condition) { // Loop-body } Flowchart:
Q: Rewrite the following while loop using a for loop. Assume the variables, x and c, have been declared…
A: Given: - Rewrite the below program with for loop
Q: Convert the do .. while loop to for loop. int main() {int i=5; do{ if((i) % 9 ==0) cout << i++ <<…
A: the code is given below :
Q: Rewrite the following code, replacing the do-while loop with a while loop. When you do this you will…
A: Modified code: #include<iostream> using namespace std;int main(){ int number; cout…
Q: Differentiate between the following, with help of examples. for loop and nested for loop while…
A: Differences between for loop and nested for loop and while and do-while loop
Q: I need to convert this to a do while loop but I don't know how
A: #include<iostream> using namespace std; int main(){ int firstNum, secNum, oddNum,…
Q: Question 3 (a) Complete the missing codes with a while loop to perform validation that prompts the…
A: a. Scanner keyboard=new Scanner(System.in); String input; System.out.print("Enter…
Q: i=10; for (int x=5; x<i; x--). The total iterations of this loop will be: O 5 infinite None of Above
A: In the given loop x-- x becomes 5,4,3,2,1.............so on the negative values so loop never…
Q: Given int variables k and total that have already been declared, use a for loop to compute the sum…
A: Code in c++: as no coding language is mentioned #include <iostream>using namespace std;int…
Q: (A) what is the number of iterations in the following for loop? #include void main() { int n;…
A: Answer : As according to the above c++ code the for loop will run n-1 times .
Q: I am having trouble with coding this in the assignment into python. It is attached as a image
A: The python code with explanation and sample output is given below: - Explanation: - Defining the…
Q: 5. Write a for loop that is equivalent to the following for loop int y = 10; while (y > 0) { y= y…
A: The given while loop prints numbers from 9 to 0. Equivalent for loop code using java is in Step 2.
Q: Using while loop int i = 1, j = 1; while (i <= 10) { System.out.printIn(i* j}; i+t; j+t; }
A: Here, I have to draw flowchart for above question.
Q: How many times will the for-loop be executed? #include 2 using namespace std; 3 int main() { for…
A: The solution for the above given question is given below:
Q: n is an integer variable. Write a while loop that prints integer numbers starting with n and…
A: You have not specified any specific language to write the program So, I have given a python program…
Q: Write a for loop that displays the following set of numbers: 0, 20, 40, 60, 80,…..1000 (Note there…
A: Here in this question we have asked to write a for loop that some display some pattern. Note -…
Q: The for loop at the top is converted into the while loop at the bottom. Identify what is wrong and…
A: Solution
Q: 3. Write a program that deliberately contains an endless or infinite while loop. The loop should…
A: Following is the java program:variables used:z is used to store the result of the multiplication of…
Q: Is this true or false? The while loop is sometimes referred to as a pretest loop since it checks its…
A: Given: Is this true or false? The while loop is sometimes referred to as a pretest loop since it…
Q: Use the variables k and total to write a while loop that computed the sum of the squares of the…
A: To compute the sum of the squares of the first 50 counting numbers. I used C++ langauge
Q: Convert the for loop in the program below to a while loop AP#include <iostream> using…
A: EXPLANATION - WHILE LOOP - In C++ language a while loop mainly executes the particular statement in…
Q: 32) Re- write the following while loop using as a for loop int i = 5; while (i < 50) {…
A: Given Pseudocode int i=5;while (i<50){ System.out.println(i+" "); i+=5; }
Q: 7. How many times will this loop run? What is the value of A after the last run? A=1; while A<18…
A: The given code of the while loop is: A = 1; while A < 18 A = 2 * A; end Here,…
Q: Write a program that reads two integers as input, and outputs the first integer and subsequent…
A: Note:- Since, the language is not defined the below program is written in Python language.…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- This question comes from the textbook:Starting out with Visual C# 5th Edition - Chapter 14 Programming Problem 2 Create an application that reads the contents of two text files and uses LINQ extension methods to perform the following: • It should display a list of all the unique words contained in both files.• It should display a list of the words that appear in both files.• It should display a list of the words that appear in the first file but not the second.• It should display a list of the words that appear in the second file but not the first.• It should display a list of the words that appear in either the first or second file but not both. Hint: Use set operations to perform these analyses. Also, see Chapter 8 for a discussion of string tokenizing.Write a program (in Java or C++), allowing to: • Create a folder "Main" • Create a file in the folder "File1" Add Read, Write permissions to "File1" Write in "File1" ● ● Read the content of "File1" ● Modify the content of "File1" Remove the Write permission of "File1" Try to write again in "File1" ● A screenshot is needed showing the results of the program execution.In C++ For this assignment, you will create a system for users to review restaurants. To review a restaurant, the user needs to login to the system first. Create a file (you can do this by hand rather than through code) named 'users.txt' and add the following information to it: User1 password steve mypassword reviewer 54321 Each line represents a user. The first word is their username and the second is their password. At the start of your main function, call a function named login, which asks for a username and password. If you find a matching username/password pair in 'users.txt', return the username. Otherwise, ask the user to try again. Back in main, assign the value returned from login to a variable. This will allow you to know which user is currently logged in. Next, build a while loop menu with the following options: •Review a restaurant. Call a function named reviewRestaurant. Ask what restaurant the user wants to review and how many stars to give it. The star amount must be…
- Using Java: A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: the name of the client the service sold ( Dinner, Conference, Lodging) the amount of the sale the date of the event. Write a program that reads such a file and displays the total amount of each service category. Display an error if the file does not exist or the format is incorrect.In C++ can someone make a code where it prompts me to login. But it has to grab a txt file and reads user name and password separated with a comma and once inputted in a code it will let me know it was successful.In Java, every source file must have the same name as the class declared in the file. Select one: True False
- IN JAVA Arrange the data for your chart in a text file as follows: The first line of the file is the title for the chart The second line of the file is the units used in the chart The rest of the file contains data values for the chart alternating with the label to print with the value on the preceding line. The program must be able to produce a chart from any data file arranged as described above. The name of the data file and the output file are provided on the command line. The program must check that there are enough command line arguments and stop with a suitable message if not. The program saves the chart to the output file (2nd command line argument); it may also display the chart to the terminal, but it is not required to. In addition to the above, accept two additional command line arguments: The maximum width for the chart (just the bar itself, not including the labels) The symbol to use for the barsIn C++, Write a program that creates a file named "myFile.txt". Write "Hello World!" ten times to the file. Part 2: Write a program that reads the file "myFile.txt. Display the content of that file on the screen.<<Write in Java>> - Challenge 7 File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a filter, reading the contents of one file, modifying the data into a code, and then writing the coded contents out to a second file. The second file will be a version of the first file, but written in a secret code. Although there are complex encryption techniques, you should come up with a simple one of your own. For example, you could read the first file one character at a time, and add 10 to the character code of each character before it is written to the second file. - Challenge 8 Write a program that decrypts the file produced by the program in Programming Challenge 7. The decryption program should read the contents of the coded file, restore the data to its original state, and write it to another file
- In Java, the File class is used to represent the data in a directory entry. Write a program that uses the File class to print all the attributes of a file.In C++ I am opening a file through a command argument and reading through it. How do you write to the file that would be opened?In C++, Query the user for the name of a file. Read the words from the file and report the number of words whose last letter is 'a', the number whose last letter is 'b' and so on, irrespective of case.