write a program in C++
Q: Write a C program that reads an integer n ≥ 2 and prints the smallest integer d > 2 such that n is…
A: Algorithm to find the factors of the given number Take input n which must be greater than 2. Take…
Q: Make a program in c++ It sums the numbers that accept the division by 3 and greater than 5 Otherwise…
A: Task : Perform the given coding task in C++. Make use of the for loop to execute the task.
Q: Write a program in c that takes in three integers and outputs the largest value. If the input is 1 2…
A: Given: Write a program in c that takes in three integers and outputs the largest value. If the…
Q: Write a program in C which reads string and rewrite it in alphabetical order. For example, the word…
A: #include <stdio.h> #include <string.h> int main (void) { char string[] = "STRING"; char…
Q: Write a C program that prompts the user to enter a positive integer between 100 and 9999 inclusive).…
A: Logic: - first check the range of input number. then count the number of digits if(count==3)…
Q: Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D,…
A: Code: #include <iostream>using namespace std; int main() { string grade; int…
Q: Write a program in c# that plays a guessing game with the user. Have your program read and store an…
A: C# program for the given problem:
Q: Write a C++ program that takes as input an arbitrary number of red blood cell counts in the range 0…
A: #include <iostream>using namespace std; int main() { int i, count ; float…
Q: Write a program in C++ that keep reading integer values until reads -1 then print the smallest…
A: #include <iostream> using namespace std; int main(){ //declaring variables int…
Q: Please write a program c++ language that gives the number of possibilities that can be formed from…
A: Program Plan: In the main() method, declare a variable named posibility to hold a number of…
Q: Write a C program that reads the value of an integer variable x and the value of a character…
A: function colorRange(int x) //char return type step 1:- Start step 2:- if (x = 0 to 10) then return…
Q: Write a program function (in any programming language) that will find and add every alternative…
A: Step 1: Note :-I am writing the program in c++ programming language:- Introduction:- Prime number is…
Q: Write a C++ program that displays the list of perfect nubers up to n. WI by the user; ensure that n…
A: Since there are multiple questions and you have not specified which question needs to be answered,…
Q: Write a program in c language to analyze the letter frequencies in a block of text. Ignore case…
A: Start. Read the characters in the string. Find the frequency of each character. Print them. Exit.…
Q: Write a C++ program to generate a random vehicle registration number that is a string of length 10…
A: Write a C++ program to generate a random vehicle registration number that is a string of length 10…
Q: Write a program in C that will add the numbers from 1 up to and including a given positive integer,…
A: In this question we are asked to write a program in C which returns the add of numbers which are not…
Q: 2 = ABC 3 = DEF 4 = GHI 5 = JKL 6 = MNO 7 = PRS 8 = TUV 9 = WXY No digits corresponds to Q and Z.…
A: Write a C program that input a single letter and prints out the corresponding digits on thephone.…
Q: Write a C - program that accepts two integers from the user and then prints the Sum, the difference,…
A: Program that accept two integer from the user and then print the operation.
Q: Write program in C++ that computes the following: y=1+1/x + 2/x^2 + 3/x^3 +...........+ n/x^n
A: Here I have taken input from the user with the value of x and n. Then I use a loop to generate…
Q: Write a program by using c++ that inputs a number and checks whether it is a perfect number or not.…
A: Program: #include<iostream> using namespace std; bool perfect(int n) { int sum = 0;…
Q: // write a program in C ++ that prints the numbers as follows using a loop. 1 2 3 4 5 1 2 3 4 1 2 3…
A: Procedure Followed: Include Header files. Start the main method. Declare variable 'n' and…
Q: Write a program in C to compare two strings without using string library functions. Test Data :…
A: Given: Write a program in C to compare two strings without using string library functions. Test Data…
Q: Write a c++ program that asks the user to enter a number and then prints all the divisors of that…
A: #include <iostream> using namespace std; int main(){ int num = 0; cout<<"\n Enter…
Q: Write a program in C++ Language to calculate the value of y from the following: (2x² y = 1 le-x* +1…
A: #include <iostream>#include <bits/stdc++.h>using namespace std; int main() { int x;…
Q: Write a C++ program that finds either a user given number is Armstrong or not. If it is Armstrong…
A: Below is the required C++ program: - Approach: - Include the header file and use the namespace.…
Q: Write a program in C++ that reads N from numbers and then sorts those numbers and finds and prints…
A: In this question, We have to take n number from the user then sort it, after that count the integer…
Q: Write a program in C++, to read a number and calculate the average of its digits, and the largest…
A: the c++ program which calculate avg of digits in entered num and also show largest digit is given…
Q: Write a code in C++: Write a program to factor a polynomial of the form x² + bx + c, where b and c…
A: This C++ program is to find the factors of a polynomial. Consider a polynomial x2+bx+c, here b and c…
Q: Write a C++ program to display the pyramid pattern of numbers 0 to 9 (decimal digits) with n rows,…
A: Maintain a step which is to be added to the present number for next number Maintain sum and count…
Q: Write a program c++ that receives the date from the user in the form of 3 correct numbers, the…
A: Lets see the solution.
Q: rite a C++ program which finds out the shifts where the substring/pattern matches the text, by using…
A: Below i have given program :
Q: Write a console application in c++ that prints the next 20 leap years. A leap year is a year in…
A: An year is said to be a leap year if it is multiple of 400 or multiple of 4 but not multiple of 100
Q: A. Write a program in "SUM.C" which reads two integers and prints out the sum, the difference and…
A: To do: Find sum, difference, product, division and remainder of two numbers. The program ask user to…
Q: Write a program in c++ for determining if a year is a leap year. In the Gregorian calendar system…
A: Coded using C++.
Q: Write a program in basic web using JS that takes three inputs: gender (boolean), age([18-55]),…
A: <!DOCTYPE html><html><body><p id="demo"></p><script> var gender…
Q: Write an interactive C program that prompts for and reads an integer number between 1,100 and…
A: Algorithm: The algorithm for the program is: Start Initialise the variables Read an integer between…
Q: Write a piece of C++ program that prompts the user for entering a number, say x, and prints: 1, 2,…
A: for (int i = 1; i <= num; i++) { cout << i << " "; } for (int i = num - 1;…
Q: Write a program in C++ Language to calculate the value of y from the following: x -4) (2x2 y ={1 +1…
A: code : - - // for pow() and exp() function #include <bits/stdc++.h>#include <iostream>…
Q: Write a program in C++ that performs a computation. Average age of 200 students distributed equally…
A: Input : Input age of 200 students in the defined range of age. Output : Print the average age of…
Q: Write a program in C++ that reads in two integers, determines and prints if the first is a multiple…
A: modulus operator is used to find the remainder obtained during division and if this is 0 then we…
Q: In C++, write a program that generates a random number for (x) to calculate A with the given…
A: I have added the comments. I have also added 3 output samples to show that every time a different…
Q: Write a program in C that accept the student registration number as input and print the product of…
A: Objective: This program reads the student registration number as user input and computes the product…
Q: Write a program in C# that will take a string and a number from user as an input, and write string…
A: Algorithm: 1. Start 2. Read name and number 3. Using for loop print the number till number becomes…
Q: Write a C-program, which reads five English words in the following order, an article (A/An/The), a…
A: Below is the required C program: - Approach: - Import the header files. Define the main function.…
Q: Write a C program that reads the income of a person and calculates his total tax according to the…
A: C Program for above : #include <stdio.h> int main() { double salary; //get the…
Q: Write a complete C++ program that prints the change in population of the the United States: p = p +…
A: #include <iostream> #include <iomanip> using namespace std; int main() { int year =…
Q: Write a Haskell program convertFraction2Binary that takes as input a fractional number between 0 and…
A: Working code implemented in Scala and appropriate comments provided for better understanding: Here I…
Q: Write a program in C that reads N numbers iteratively and prints biggest and smallest of these…
A: #include <stdio.h> int main(){ /* Declaring an array, number of elements(N), Index of…
Q: Write a C++ program that takes as input an arbitrary number of red blood cell counts in the range 0…
A: #include <iostream> using namespace std; int main() { //declaring variables int n;…
Q: Write a complete C++ program that reads two whole numbers into two variables of type int and then…
A: #include<iostream>using namespace std;int main(){int…
write a
Fibonacci Numbers
The Fibonacci numbers are defined by the sequence
f1 = 1
f2 = 1
fn = fn-1 + fn-2
Reformulate that as
5
t1 = 1;
t2 = 1;
nextTerm = t1 + t2;
After that, discard t1, which is no longer needed, and set t1 to t2 and t2 to nextTerm.
Repeat fnew an appropriate number of times. Implement a program that given a number
N, prints the first N numbers in the Fibonacci sequence. For example, given the number
8, the output is
The Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, 21
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- T/F The << operator is overloaded to input data items of fundamental types, strings and pointer valuesIn C++ Declare a constant “ SIZE = 5 ” Declare an array of ints , of size SIZE . Initialize that array to have the values 10, 12, 15, 19, 6 . – Write a loop that calculates and prints out the minimum value of the array. – Write a loop that calculates and prints out the maximum value of the array. – Write a loop that calculates and prints out the average value of the array.C++ Create a class Student that contains three members: roll no, name and mark, and three functions. Write a first inputStudent() function to get data of student class. Write a second getMark() function that returns a student’s mark. Write a third display() function that displays a student’s data. In a main() function, you need to declare 40 students and get data of all students by using inputStudent() function. And also use a pointer array to keep all students by mark greater than 50 and display the searching data of each student in that pointer array (Use the access operator -> to access a pointer points to member functions of the Student class).
- 1. Mark the following statements as true or false. a. An identifier must start with a letter and can be any sequence of characters. (1) b. In C++, there is no difference between a reserved word and a predefined identifier. (1) c. A C++ identifier cannot start with a digit. (1) d. The collating sequence of a character is its preset number in the character data set. (2) e. Only one of the operands of the modulus operator needs to be of type int. (3) f. If ; and ;, then after the statement ; the value of b is erased. (6) g. If the input is 7 and x is a variable of type int, then the statement ; assigns the value 7 to x. (6) h. In an output statement, the newline character may be a part of the string. (10) i. In C++, all variables must be initialized when they are declared. (7) j. In a mixed expression, all the operands are converted to floating-point numbers. (4) k. Suppose . After the statement ; executes, y is 5 and x is 6. (9) i. Suppose . After the statement ; executes, the value of a is still 5 because the value of the expression is not saved in another variable. (9)(Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays so that a customer’s record can be accessed randomly by account number. Create the file by entering five customer records, with each record consisting of an integer account number (starting with account number 1000), a first name (maximum of 10 characters), a last name (maximum of 15 characters), and a double-precision number for the account balance. After the file is created, write a C++ program that requests a user-input account number and displays the corresponding name and account balance from the file.(Initialize array) Write a function called initializeArray that receives an array, its size, and two integers and initializes the array with random values between the first integer and the second integer. Write another function called printArray that receives an array and its size and prints the array elements in a column. Write a test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive, and then prints the array using the above functions Write a C++ program that declares and initializes an integer array of size 100 with random integers between 1 and 10 inclusive using initializeArray (from question 1) and counts the occurrence of each number in the array and graphs the information in the form of a bar chart or histogram—each number is printed, then a bar consisting of that many asterisks is printed beside the number. Here is a sample run of the program: Number Value Histogram 1…
- (Initialize array) Write a function called initializeArray that receives an array, its size, and two integers and initializes the array with random values between the first integer and the second integer. Write another function called printArray that receives an array and its size and prints the array elements in a column. Write a test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive, and then prints the array using the above functions Write a C++ program that declares and initializes an integer array of size 100 with random integers between 1 and 10 using initializeArray (from question 1) and counts the occurrence of each number in the array and prints the occurrences. Note: Print time or times correctly. Hint: Declare another array called count that stores the number of each value as you count the numbers of the original array. Use printArray (from question 1) to print the values of count. Here is a sample run of the program: 1…C++ Struct Pointers Help: I have a file called names.txt. Write a program that reads each line and then store the name and nickname under an individual pointer to the class Person. names.txt: Norman, Normie Justine, Jussy Richard, Dick Shelley, Shell class Person { public: string name; string nickname; Person(string name, nickname) { this->name=name; this->nickname = nickname; } }; Print out each pointer's name and nickname to verify that it has been stored.pls debug this pseudocode // A high school is holding a recycling competition,// and this program allows a user to enter a student's // year in school (1 through 4) and number of cans collected// for recycling. Data is entered continuously until the user// enters 9 for the year.// After headings, output is four lines --// one for each school year class.start Declarations num year num cans num SIZE = 4 num QUIT = 9 num collectedArray[SIZE] = 0, 0, 0 string HEAD1 = "Can Recycling Report" string HEAD2 = "Year Cans Collected" output "Enter year of student or ", QUIT, " to quit " input year while year <> QUIT output "Enter number of cans collected " input cans collectedArray[year] = collectedArray[year] + cans output "Enter year of student or ", QUIT, " to quit " input year endwhile output HEAD1 output HEAD2 year = 1 while year < SIZE output year, collectedArray[year] year = year + 1…
- C++ Dynamic Programs Hoskins College offers both curriculum and continuing education courses. Write a program that dynamically tracks these courses using an array of object pointers. Every course (both curriculum and continuing education) has a course id, title, room number, and number of contact hours. A curriculum course has credit hours and tuition rate. Tuition is calculated by multiplying the course's credit hours by tuition rate. A continuing education course has a flat fee (cost). Implement a show() function in every class that displays the data in the object. Part A: Create an inheritance-based collection of classes to represent these different courses. Include code in main to test your work by instantiating objects of the two derived classes. Part B: Modify your program. Remove the objects you created in main to test the classes. Modify the base class so that show() becomes a virtual class. In main, create a single array capable of holding pointers to objects of both…(Evaluate expression) Modify Listing 20.12, EvaluateExpression.java, to addoperators ^ for exponent and % for remainder. For example, 3 ^ 2 is 9 and 3% 2 is 1. The ^ operator has the highest precedence and the % operator has thesame precedence as the * and / operators. Your program should prompt theuser to enter an expression. Here is a sample run of the program: Enter an expression: (5 * 2 ^ 3 + 2 * 3 % 2) * 4(5 * 2 ^ 3 + 2 * 3 % 2) * 4 = 160 Here is the Listing 20.12 to modify: import java.util.Stack; public class EvaluateExpression { public static void main(String[] args) { // Check number of arguments passed if (args.length != 1) { System.out.println( "Usage: java EvaluateExpression \"expression\""); System.exit(1); } try { System.out.println(evaluateExpression(args[0])); } catch (Exception ex) { System.out.println("Wrong expression: " + args[0]); } } /** Evaluate an expression */ public static int evaluateExpression(String expression) { // Create operandStack to store operands…[In c#] Write a class with name Arrays . This class has an array which should be initialized by user.Write a method Sum that should sum even numbers in array and return sum. write a function with name numFind in this class with working logic as to find the mid number of an array. After finding this number calculate its factorial.Write function that should display sum and factorial.Don’t use divide operator