5. Write a program to read in an integer (long) and display all pairs of factors of the input integer. That is, the output must be given as a list of pairs of factors such that the product of each pair is the input integer. Then, print which of these pairs contains only prime numbers (there can be either 1 such pair or none). Note that a. the Scanner class supports a nextLong method to read a long integer, nextBigInteger to read a BigInteger, and nextBigDecimal to read a BigDecimal. b. the printf method uses %d for int, long, BigInteger; and %f for float, double, and BigDecimal.
use the below code for the above question
and insure that while executing the code #include <vector> is working in Trubo C++.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int k;
cin >> k;
int k1;
for(k1 = 1; k1 <= k; k1++) {
int N;
cin >> N;
vector result;
result.push_back(1);
int temp, carry = 0;
for(int i = 2; i <= N; i++) {
for(int j = 0; j < result.size(); j++) {
temp = carry + result[j] * i;
carry = temp / 10;
result[j] = temp % 10;
}
while(carry) {
result.push_back(carry % 10);
carry /= 10;
}
}
for(int i = result.size() - 1; i >= 0; i--){
cout << result[i];
}
cout << endl;
}
return 0;
}
5. Write a program to read in an integer (long) and display all pairs of factors...
14.8 Prog 8 Overload methods (find avg) Write a program to find the average of a set numbers (assume that the numbers in the set is less than 20) using overload methods. The program first prompts the user to enter a character; if the character is 'I' or 'i', then invokes the appropriate methods to process integer data set; if the character is 'R' or 'r', then invokes the appropriate methods to process real number data set; if the inputted...
Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...
Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to convert (a String) Accept that String Prompt the user for the value of the initial base (an integer) Accept that integer Prompt the user for the desired base of the output (an integer) Accept that integer If the String is not a legal expression of a number in the initial base, display an error message and exit the...
Write a program to read two integer values and print true if both the numbers end with the same digit, otherwise print false. Example: If 698 and 768 are given, program should print true as they both end with 8. [Hint: The % operator can be used to find the remainder.] At the time of execution, the program should print the message on the console as: Enter two integer values : For example, if the user gives the input as...
Create a method based program to find if a number is prime and then print all the prime numbers from 1 through 500 Method Name: isPrime(int num) and returns a boolean Use for loop to capture all the prime numbers (1 through 500) Create a file to add the list of prime numbers Working Files: public class IsPrimeMethod { public static void main(String[] args) { String input; // To hold keyboard input String message; // Message...
Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays their values: 1. Declare a character variable with value 'a', and display the character using printf with a %c format. Then add a second printf that displays the character with a %d format. 2. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your...
Write a program that contains the function measure() that is to accept a long integer number total and the addresses of the integer variables inches, feet, yards, and miles. The passed long integer represents the total number of inches, and the function is to determine the number of miles, yards, feet, and inches in the passed value, writing these values directly into the respective variables declared in the calling function. This function will be called from the main program and...
Implement a program to display each digit from the given an integer. Your program should satisfy the following requirements The program should have a function called public static void displayDigit(String number) {...} that print all digits from the given number Your program should have a public static void main method to test your method displayDigit Your program should use Scanner class to accept input from the end-user Sample runs: If the end-user enter 1234, the program should return 1,2,3,4 If...
Create a program (in C, not C++) called lab3.c that declares the following variables and displays their values: Declare a character variable with value 'a', and display the character using printf with %c format. Then add a second printf that displays the character with a %d format. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your assignment - so...
Q1 SUMMER2020- nts python language Example Write a program to read an integer r then print a triangle with r number of rows using .asterisks Result Input 5 Hint: Use end= parameter of the print function to not add a newline to the end of the string * * * * * * * * * * * * 9 - عام python language Course Information o Course Material Assignments o example input Lab Exercises Quizzes Result 7.0 ACUTE 7.0...