What is the following c program find? int fun1(int n){ int i,f=1; for(i=1;i<=n;i++) { f=f*i; } return f: } void main() { int N,X; scanf("%d",&N); X=fun%; printf(%d\n",N,X); } a. square of a given number root of a given number O c. Prime of a given number d. factorial of a given number
Q: Consider a function defined as follows for non-negative integers n and m: A(0, m) = m+1 A(n, 0) =…
A:
Q: Exercise : Write a C++ program that computes and returns: • the smallest positive integer (n) for…
A: Program Approach: Including a necessary header file Defining method compute Declare variable 0 to n…
Q: Write a simple C program that can determine whether a machine is little- or big-endian. 2. Printing…
A: Here is the solution:-
Q: please write it in C language. import java.util.*; public class EightQDfs { final int…
A: Step 1: Declare the function dispSol() that takes board configuration in the form of a…
Q: Write a program that prints out true or false depending on comparisons that you make. Make sure that…
A: All types of operators are used in the code + - * / % > >= == <= < != The complete…
Q: Task: Write a C++ program using variables and loops in order to implement the Hi-Low strategy of…
A: #include <iostream> using namespace std; int main() { // Variable that stores the correct…
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: This is for Java Write a recursive function that takes as a parameter a nonnegative integer and…
A: Here, first you need to declare one variable for taking input from user. For taking input from user,…
Q: Estimate the time complexity for the following C+ program: III I/ Start //I/I/ #include const int…
A: The time coplexity of main Function is O(N^2). I will show you the time complexity of this function…
Q: c) Estimate the time complexity for the following C+ program: #include const int n=10; int Fact…
A: Time complexity is used to check the time the time required to execute the program.lesser the time…
Q: Write a program in C++ language to find the result of this program: #include #include main( ) int…
A: Given: Find the output of the given program.
Q: Write a C++ program that reads five cards from the user, then analyzes the cards and prints out the…
A: Program: #include <iostream>using namespace std;const int numCards = 5; // function…
Q: Show the output of the following programs. (Hint: Draw a table and list the variables in the columns…
A: Given: Show the output of the following programs. (Hint: Draw a table and list the variables in the…
Q: Loops question. Write a C program that reads an integer k from the user and then prints the…
A: The main objective of the C program, main. c is to prompt the user to enter a value and read the…
Q: marks as given below. Calculate the overall percentage (sum of the total points earned divided by…
A: Given Write a program in C++ that calculates the total grade of a student for N number of quizzes.…
Q: Write a short C++ or Python program to support your answer (for example, show that you checked…
A: - We need to check for that the smallest number for the equation given is f that we check. - We are…
Q: Please solve Quickly C++ programming language Drag and drop to finish a program prints the…
A: The code below prints the pattern shown in above questions.
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: C++ Given an integer num, repeatedly add all its digits until the result has only one digit, and…
A: Below is the required code in C++ with O(1) runtime and sample output:
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 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: a) What output will be printed for input value x = 8 ? (b) How many dierent input values x cause…
A: The given code simply adds each bit and get 2^b, and return b + 1, For
Q: Write a complete C++ program that reads a positive and non-zero integer then do the following: 1.…
A: Note: 2. Divisors of number 20 are: 10, 5, 4, 2, 1. Therefore, even divisiors are 3 and not 4. 3.…
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: Consider the following C++ code: int n = 1; // global printl (int x) { cout << x + n; } plus n() { n…
A: Hi there, Please find your solution below, I hope you would find my solution useful and helpful.…
Q: Write a program in C++ that reads N of numbers and ther sorts those numbers and finds and prints the…
A: I have provided detailed code for given question in c++ below.
Q: Write a recursive function int fib (int n) to compute the Fibonacci numbers where n is a positive…
A: code snippet:
Q: Write a C program that takes a positive integer N from the user as input. If the user inputs a…
A: Required: Write a C program that takes a positive integer N from the user as input. If the user…
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 C++ program using classes and recursion functions to convert a number in a given base (the…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write a programe in PYTHON to Write a recursive function that takes positive int n as its input and…
A: Program Approach: Defining method sum_squares Using if the method to check n is equal to 0 Defining…
Q: Write a C++ program using classes and recursion functions to convert a number in a given base (the…
A: Steps to be followed: Include required header files. Create a class named Conversion: Declare…
Q: a Java program that applies the Newton-Raphson's method xn+1 = xn – f(xn) / f '(xn) to search the…
A: class NewtonRaphson { // The function whose root we are trying to find // ax^6 - bx^5 + cx^4 -…
Q: Write a C++ program: to iteratively compute Fibonacci numbers (named after an Italian…
A: A C++ program to generate fibonacci series using recursion is given below,Program://Declare header…
Q: You need to write the code in java. Consider a post office that sells stamps in three different…
A: The following code can be used to implement the given requirements. import java.util.*;import…
Q: Implement a recursive C++ function which takes a character (ch) and a positive integer (n) and…
A: #include<bits/stdc++.h> using namespace std; //the print function void printNTimes(char ch,…
Q: Write a C++ Program using using classes, that, given a number greater than zero (0), the user will…
A: The complete code is a given below .
Q: write a c++ program that asks user to enter a number and then print the number that is maximum time…
A: #include<iostream> using namespace std; int main(){ int n, x, max_count=0; cout…
Q: Write a program in c++that reads a positive integer n, and prints the first n even numbers. For…
A:
Q: Write a c++ program that asks the user to enter an integer number and then by a recursive function…
A: Algorithm: Step-1: Start Step-2: Take an integer n from user Step-3: Call recursive function add and…
Q: Consider the following C++ code: int n = 1; // global print1 (int x) { cout << x + n; plus_n () { n…
A: We are given a C++ code for which first we will find out the output produced by it and then we will…
Q: Write a C++ program that checks if a number is Palindrome (use recursive function as you code). A…
A: Start define a recursive function rev that calculates reverse input integer number if reverse is…
Q: Below is C code and Python code for an algorithm. C code: 1: void foo( int n, int A, int B, int C )…
A: Answer:
Q: Write a program in C++ to print even or odd numbers in given range using recursion. Test Data: Input…
A: Code: #include <iostream>using namespace std;void printEven(int start,int end){…
Q: Write program in f# only Please solve it Asap Please write the program to returns the larger value…
A: Code let max n1 n2 : int32 = // function body if(n1>n2)then n1 else n2 let result = max 40 45…
Q: .The following is the C code that you need to implement for this lab: uint8_ t f(uint8_tn)…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: { int A[n][n]; for(int i=0;i>A[i][j]; BSort(A);
A: estimate the time complexity for the following c++program #include<iostream.h>const int…
Q: In java Reprogram the following iterative function with recursion. int f(int N) { int…
A: The equivalent recursive function for the given iterative function is as follows, //Define recursive…
Step by step
Solved in 6 steps with 4 images
- Translate this C program to Java #include<stdio.h>int main() { int n; printf("Enter the number of cash: "); scanf("%d",&n); int a[n]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } printf("Total:\n"); int sum=0; for(int i=0;i<n;i++){ sum=sum+a[i]; if(i!=n-1) printf("%d + ",a[i]); else printf("%d = ",a[i]); } printf("%d",sum);}Write a program in C that take 5 digit number as an input from the user and perform the following tasks:1. Split a number into digits.2. Find the sum of the all the digits in the number.3. Find the product of the all the digits in the number.4. Find maximum number with in the number along with position.5. Printing the digits in the reverse order.Loops question. Write a C program that reads an integer k from the user and then prints the multiples of 1 up to k, the multiples of 2 up to k/2, etc. For k = 10, the printout would be 1,2,3,4,5,6,7,8,9,10, 2,4,6,8,10 3,6,9 4,8 5,10,
- Instructions: Kindly provide comments that explains the program code below. (NOTE: this is a C program language) #include <stdio.h> int fact_recur(int n){if(n==0) return(1);return(n*fact_recur(n-1));} int fact_for(int n){ int fact=1; for(int i=1;i<=n;i++){ fact=fact*i; return fact; } }int main(void) { int number; printf("input number is: "); scanf("%d",&number); printf("factorial using for loop: %d",fact_recur(number)); printf("\nfactorial using recursion: %d",fact_recur(number)); return 0;}In this c++ program you are asked to design a 2 x 2 x 2 Rubik's cube that is filled with numbers instead of colors. The cube, naturally, has six sides that are identified as follows: The front side is side 0 The right side is side 1 The backside side is side 2 The left side is side 3 The Up side is side 4 The bottom side is side 5 The squares on every side are initially filled with the same side index. This means that the four squares on the front side are filled with 0's, the four squares on the right side are filled with 1's, etc. You are allowed to move the cube in two directions only: Horizental move (H or h): The first row moves one step in four sides in this order (0 -> 1 -> 2 -> 3 -> 0) Vertical move (V or v): The left column moves one step in four sides in this order ( 0 -> 5 -> 2 -> 4 -> 0) The program accepts from the the user the number of moves he/she wants to make, accepts the sequence of desired moves as shown in the sample case below.…Write a program in C++ that lets the user input an odd number of positive integers ( each separated by one space). Assume that each integer except for one, the exclusive integer, appears an even number of times in the input. The program should output the exclusive integer. Example: Enter integers: 2 1 55 3 2 1 4 4 2 2 55 Exclusive: 3
- Determine whether a string is a palindrome A palindrome is a string of characters that reads the same from right to left as it does from left to right, regardless of punctuation and spaces. Some famous English palindromes include the following “Madam, I’m Adam”, and “Never odd or even”. Of course, a simpler example would be the world “radar”.The specifications for this assignment are: Write and test a non-recursive solution in Java that determines whether a string is a palindrome •Your program should consist of at least two methods: (1) the main method (2) the method which performs the task of determining whether the specified string is a palindrome. You should name this method isPalindrome. You should name the class that contains your “main” method and the isPalindrome method FindPalindrome. •You must use a Stack and a Queue in your solution:Make sure to Write your own Stack and Queue based on the Vector in the Java API and use those in your solution. You should name those classes…Write a complete C++ program that reads a positive and non-zero integer then do the following: 1. Print all odd divisors (factors) of that integer in decreasing order. 2. Print the count of all even divisors. 3. Keep dividing the previous number by 2 until that number reaches zero then print how many times the division was executed. • Example: If the number 20 The odd divisor of 20 is 5, 1 in decreasing order The count of all even divisor is 4 The division was executed 10 timesSolve all the errors in the below method of C# language step by step and comment the error by correcting it. internal static void ReverseWordOrder(string str) { int i StringBuilder reverseSentence = new StringBuilder(); int Start = str.Length ; int End = str.Length - 1; while (Start > 0) { if (str[Start] == ' ') { i = Start while (i <= ) { reverseSentence.Append(str[i]); i++; } reverseSentence.(' '); End = Start - 1; } Start-; } for (i = 0; i <= End; i++) { reverseSentence.Append(str[i]); } Console.WriteLine(reverseSentence.ToString());
- Write a Java program Primes that finds all possible prime numbers in the range of (1, n], where 1 < n ≤ 1000. Solve the problem by implementing and using the helper method isPrime(number) which determines whether the given argument is prime or not. Example: Input 5 Output 2 3 5 (Consider the structure of the code that is given in the picture. The structure must be the same)in Java, Write a program that reads student scores, gets the best score, and then assigns grades based on the following scheme:• Grade is A if score is ≥ best − 10• Grade is B if score is ≥ best − 20;• Grade is C if score is ≥ best − 30;• Grade is D if score is ≥ best − 40;• Grade is F otherwise.The program prompts the user to enter the total number of students, then prompts the user to enter all of the scores, and concludes by displaying the grades. Here is a sample run: number of students: 4 scores are: 40.0, 55.0, 70.0, 58.0 Student 0 score is 40.0 and grade is C Student 1 score is 55.0 and grade is B Student 2 score is 70.0 and grade is A Student 3 score is 58.0 and grade is BWrite a simple program in C++ that lets the user input a single integer n where 1 ≤ n ≤ 100000. The program should print the sum of the first n prime numbers. In the first example below, the first 5 prime numbers are 2, 3, 5, 7, and 11. Example #1: Enter integer: 5 Prime sum: 28 Example #2: Enter integer: 100000 Prime sum: 62260698721