9. What is the output of the following C++ code? int alpha[8]; 0; i < 4; i++) { i * for (int i alpha[i] ( i + 1); if (i % 2 0) == alpha[4 + i] alpha[i] + i; else if (i 응 3 0) === alpha[4 + i] else if (i > 0) alpha[i] i; alpha[4 + i] alpha[i] alpha[i 1]; } 0; i < 8; i++) cout << alpha[i] << " "; for (int i cout << endl;
Q: Write a c++ program that takes a string of letters in an array and outputs the number of characters…
A: The string is a character array that stores the character into the string in sequential order. The…
Q: What will be the output of the following C++ code? #include #include using namespace std; class B {…
A: Classes in C++: A user defined data type that works as an object. A class is used to lay down the…
Q: Output each floating-point value with two digits after the decimal point, which can be achieved by…
A: Program Explanation: Include the necessary header files. Use namespace std. Define the main…
Q: What will be the output of the following C++ code? 1 #include 2 int main() 4 int p - 123 int t-…
A: task: is to give output of the code provided in the question.
Q: .Write a function: int calculate(int x); In java, the function returns value of 3*x^3 + 3*x^2 - 2.
A: import java.util.*;public class Main{ public static void main(String[] args) {…
Q: What is the scope of identifier x which is declared in Line 4? Consider the following program: const…
A: Scope of the variable: Local variable: Variables declared inside the function or block are called…
Q: A company wants to secure users' passwords that consists of four digits only by encrytping them.…
A: The programming methodology for the program is given by: Including header files Function prototype…
Q: I keep getting the error "undefined reference to 'main'". What am I doing wrong? Here is the code,…
A: #include <stdio.h>#include <stdlib.h>#include <string.h> int main(){char…
Q: The aim of this program is to ask for inputting the three sides of two triangles, constructs the two…
A: EXPLANATION: There is no parameterized constructor for the given class, and therfore when the…
Q: What is the output of the following C++ code? class Point { private: int x; int y: public: Point(int…
A: We need to find the output of the given code.
Q: What is the ouput of the following C code segmer void * T( void* me) { int s=0; for (int k=1; k<=me;…
A: It is defined as a powerful general-purpose programming language. It can be used to develop software…
Q: Section 1: FIFO Page Replacement Algorithm In FIFO page replacement, the pages are simply placed in…
A: Start Declare the size to page length Check the need of replacement from the page to memory Check…
Q: Write down the output on the screen, when the following c program fragments of code are executed:…
A: code -1 int i,sum=0; \\(initial sum value is zero ) for(i=10 ; i>0 ;…
Q: Could you write this code in c language for me in the same way? #include #include using…
A: C Code :- #include<stdio.h> #define MAX 80int mat[MAX][MAX]; void fillRemaining(int i, int j,…
Q: 2. Write a program that constructs a random telephone number of the form (XXX) xXX-XXXX and outputs…
A: code snippet:
Q: Consider the definition of the class integerManipulation . What is the output of the following C++…
A: Explanation: In the given code, the function “classifyDigits()” is used to count the total number of…
Q: Suppose that the first number of a sequence is x, where x is a non-zero positive integer. We define…
A: C++ Program for above : #include <iostream> using namespace std; int main() { char…
Q: 2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and outputs…
A: Dear Student, The complete source code for the asked program is given in step 2 also comments have…
Q: Part 1 Count the occurrences of a single character in a string. Example output: $ ./lab02 foobar o $…
A: The above code is wrong and has errors. The correct C program for the above problem is given in the…
Q: void my_func(int i, int& j) { int k; 6; k = i + i = i * 2; j = i + 3 + k; 1. What is the output of…
A: To invoke the given function definition in the program and to find the output
Q: f. Write a JAVA program to calculate the determinant using the formula B? - 4*A*C, and then…
A: Given, We have to write a JAVA program to calculate the determinant using the given formula. Given…
Q: Write a C program that reads integers, finds the sum and the average of them. Assume that the input…
A: #include<stdio.h> float computeAverage(float sum,int counter){ return sum/counter;} int…
Q: Examine the following code segment and consider what variable bindings will be visible at various…
A: The given program is below: int h, i; // global variable of int type void B(int m) { // function…
Q: Write output of the following c++ code by completing it with explanation of all iterations. Code…
A: Here in the main method, we have defined a variable x of type integer. Now we have a call to…
Q: Consider an int *a and an int n. If the value of %ecx is a and the value of %edx is n, which of the…
A: To which assembly snippets best corresponds to the C statement return a[n]?
Q: What is the scope of identifier x which is declared in Line 10? * Consider the following program:…
A: Given: To choose the correct option.
Q: C programming #include int main() { int i, j, n ; printf("height? ") ; scanf("%2d", &n) ; for (i =…
A: Answer: program 1:- #include <stdio.h> int main() { int i, j, n ; printf("height? ") ;…
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: java please, Complete main() to read dates from input, one date per line. Each date's format must…
A: As specified above : Using scanner class, a list of dates is taken as input. By using substring(),…
Q: Can someone help me to improve the following code in C and make it functional? #include #include…
A: C language C is a high-level, all-purpose programming language that is perfect for creating…
Q: Q4 a. Using user-defined classes and methods only write a C++ program to solve for the equation…
A: C++ program to solve the given problem.
Q: What is the value of "a" such that the following expression "b = 35 % 6 + a * a/ 7;" assigns "b"…
A: Task : Choose the correct option for given question.
Q: In c void f (int *p, int * const q) { p=q *p=3; *p=4; }
A: The pointer in C language is a variable which stores the address of another variable.
Q: Write a program in C++ that lets the user enter some English text, then converts the text to…
A: Given : Write a program in C++ that lets the user enter some English text, then converts the text to…
Q: The charge for all signs is a minimum of $35.00. The first five letters or numbers are included in…
A: Input count of characters, make and color and based on them add respective costs Print final cost
Q: What is the output of the following C++ code? class Point { private: int x; int y: public: Point(int…
A: What is the output of the following C++ code? class Point { private: int x; int y public: Point(int…
Q: Write a C++ program that breaks string s1 into "tokens" ( logical pieces such as words in a line of…
A: strstr() is the apparatus you are searching for. It can find a string inside another string.…
Q: In JAVA A function foo takes three integers as input arguments, i.e., foo(int a, int b, int c). The…
A: A function foo takes three integers as input arguments, i.e., foo(int a, int b, int c). The three…
Q: Question 12 Consider the following program written in C pseudocode: void foo(int x, int y){ y = y +…
A: Please give positive ratings for my efforts. Thanks. ANSWER a) Passed by value a = 6…
Q: Given the following C++ code const int size=5; int Num[size]; for (int i = 0; i < size; i++)…
A: Here we create a array of size 5 int Num[size]; Then this loop for(int i=0;i<size;i++)…
Q: Describe the execution of the following program segment. int a [5]={-1,8,3,9,7} , *pt; 2. 1. pt =…
A: If an array assigned to the pointer then the pointer points to the first element of the array. It is…
Q: Consider the following code: Int a=5,b=a++ - 2; a)Explain what happened in above code?
A: The variable "a" is initialized with value "5", and the variable "b" is initialized with the value…
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: Consider the following C++ code and answer the questions: const int size=5; int Num[size]; for…
A: EXPLANATION - a) Value of *Num is 1 . A program is created . In main function the variable named…
Q: 2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and outputs…
A: As no language is mentioned I am doing is using JAVA. As the number is generated randumly So, It…
Q: What is the scope of identifier Sum which is declared in Line 6? * Consider the following program:…
A: D) Line 6 to Line 9
Q: TTTT Vrite a function in Java that implements the following logic: Given a number n, return true ifn…
A: Logic:- if n>=1 && n<=10 return true else if(outsideMode==true) If(n<=1 ||…
Q: 05: Consider the following Java program: public void fun(void) { int a, b, c; /* definition 1 */ ...…
A: The java program: public void fun(void) { int a, b, c; /* definition 1 */ . . . while (.…
can you please explain in detail what is done throughout the program?
Thank you!!
Step by step
Solved in 2 steps
- Consider the following C++ function. int mystery(int num1, int num2){if (num1 > 0){for (int i = 1; i <= num1; i++)num2 = num2 * i;return num2;}else if (num2 > 0){for (int i = 0; i <= num2; i++)num1 = num1 + i;return num1;}return 0;}What is the output of the following statements?a. cout << mystery(4, -5) << endl;b. cout << mystery(-8, 9) << endl;c. cout << mystery(2, 3) << endl;d. cout << mystery(-2, -4) << endl;In C, Assume that the int variables i and j have been declared, and that n has been declared and initialized.Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consisting of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be******You should not output any space characters.Use the following skeleton code to write a C program (NOT C++) which filters out words from input which can be typed entirely with either the left hand (QAZWSXEDCRFVTGB) or right hand (YHNUJMIKOLP) #include "general.h" int main(void){int pipe1[2];/*pipe for child 1 and 2 to share*/int pipe2[2];/*pipe for child 2 and 3 to share*/int status; /*setup pipe 1*//*Fork and call child 1 process. /*parent closes pipe ends it no longer needs*/ /*set 2nd pipe*/ /*Fork and call child 2 process. Don't forget to close any fds you will not want open in the childbefore you call the child routine */ /*parent closes pipe ends it no longer needs*/ /*Fork and call child 3 process.*/ /*parent closes. rest of pipe ends*/ /*wait for all 3 children*/ return(0);}
- Write a C program that compute the perimeter of Circle, Rectangle, Triangle and Square. The program asks the user to specify the shape as follows: C for Circle, S for Square, R for Rectangle and T for Triangle and then it reads the required value to compute the perimeter for that specified shape. Note: the perimeter for the shapes:????l? = ? × ?????? × ?S????? = ? × ????????????? = ? × (????? + ??????) ???????? = ????? + ????? + ????3Consider the following C function or Java method (except for final printstatement the code is the same):void fun (int x) {int a, b, c, d;d = 1;for (a = 1 ; a <= x ; a ++) {b = a;c = 1;while (b > 0) {c &= b % 2;b /= 2;}d += c;}printf ("%d\n", d);}void fun (int x) {int a, b, c, d;d = 1;for (a = 1 ; a <= x ; a ++) {b = a;c = 1;while (b > 0) {c &= b % 2;b /= 2;}d += c;}System.out.println (d);} (a) What output will be printed for input value x = 8 ?(b) How many dierent input values x cause the function to print theresult 8 ?(c) Write a function with the same behavior but only one loop (of anytype) and no library call except for the print statement.What is the output of the following C++ code? #include<iostream> using namespace std; class X { int m; public: X() : m(10) { } X(int mm): m(mm) { } int getm() { return m; } }; class Y : public X { int n; public: Y(int nn) : n(nn) {} int getn() { return n; } }; int main() { Y yobj( 100 ); cout << yobj.getm() << " " << yobj.getn() << endl; }
- This is for c++. I need a program that asks whether any members of your party are vegetarian, vegan, or gluten-free, then displays only the restaurants that you may take the group to.WRITE CODE IN C LANGUANGE On their way down the river, Jojo and Lili saw two frogs each in position X1 and X2. The two frogs are seen jumping happily towards the same direction that is come to Jojo. After watching the two frogs, Joio and Lili saw that the speed the two frogs are different. The first frog to start jumping from position X1 has a speed of v1, while the second frog that starts to jump from position X2 has a speed of V2. Joig guess that "YES" both frogs will be in the same position in a certain time T, while Bibi guessing "NO" the two frogs will never be in the same position in time. Help Joio and Lili calculate the frog's movements to determine whether the guess they are rightWrite a C program that reads an integer from the user (keyboard), namely n. Your program should print all positive numbers that are smaller than n and satisfy the following condition: If we denote the number with a and sum of its digits b then a+b is a perfect square. You should print the numbers in ascending order and print their digits separated by “-“ symbol from the least significant to the most significant on the same line as the number. At the end of each line you should also print a+b. Example: If the user enters n : 150, then the output should be as follows: 2 2 4 8 8 16 17 7-1 25 27 7-2 36 38 8-3 49 72 2-7 81 86 6-8 100 135 5-3-1 144
- Write a C program that reads an integer from the user (keyboard), namely n. Your program should print all positive numbers that are smaller than n and satisfy the following condition: If we denote the number with a and sum of its digits b then a+b is a perfect square. You should print the numbers in ascending order and print their digits separated by “-“ symbol from the least significant to the most significant on the same line as the number. At the end of each line you should also print a+b. Example: If the user enters n : 150, then the output should be as follows: 2 2 4 8 8 16 17 7-1 25 27 7-2 36 38 8-3 49 72 2-7 81 86 6-8 100 135 5-3-1 144 but i cannot use while loop and #include <math.h>Write a program in C that displays the classic BINGO game, displays a BINGO card (5x5 square), and tests the bingo card for a winner via 2 users Steps: 1- Ask user 1 to enter 24 numbers between 10-40 no duplicates / check for range and repetition 2- Ask user 2 to enter 24 numbers between 10-40 no duplicates / check for range and repetition 3- Design 2 BINGO cards as you see below 4- Distribute the numbers onto the 2 cards with each user input with 0 in the middle 5- Display the 2 cards in 1 screen as you see below 6- Generate a random number between 10-40 no duplicates / check for range and repetition 7- Compare the random number with the numbers on the 2 cards 8- If the random number matches any number on each card, change the number on the card to 0 9- Check for winning cards 5 numbers in a row or column = 0 5 numbers in a diagonal = 0 all 4 corners of the card = 0 if any of the players won, display who is the winner and exit the program if the 2 players won, display both are…(IN PYTHON) Problem 2 Write a function count_8s(string) that performs the following actions: Receives a single parameter called string that we expect to be a string. If we receive something that is NOT a string, raise a TypeError with the message “Non-string input received.” Uses recursion to count the number of eights in the string. Use a string of length 0 as your base case. Otherwise, determine if the first character in string is “8” or not, and call count_8s() again with the rest of the string as an argument. Returns the number of eights found in the string. NOTE: You are not to use a while or for loop in your code.