5.12 LAB: Convert to binary Write a program that takes in a positive integer as input, and outputs a string of 1's and O's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Outnut modulo 2 (remainder is either 0 or 1)
Q: Q3 Let U = {5, 6 }, write an equivalent to the following assertions: 3x P ( x ) v - Vx Q ( x ) Q4.…
A:
Q: 7.11 LAB: Print string in reverse Write a program that takes in a line of text as input, and outputs…
A: - We need to highlight the code to reverse a string till we get the letter d for the word done.
Q: int [] X = {12,15,12}; int [] Y = {1,2,3}; int i=0; for(int a:X) %3D if(a%2==1) { Y[i]=a; i++; else…
A: I have given an answer in step 2.
Q: 49- Find the output of the following program. main(){ int a = 10, b, c; = a++; %3D C = a; %3D cout…
A: The correct option is option 3rd that is 11 10 11
Q: You are given some coins. You have to take some coins from the given coins such that the sum of the…
A: NOTE: You have not mentioned the programming language so I did in C++ In this question, you have to…
Q: 5.18 (Even or Odd) Write a program that inputs a series of integers and passes them one at a time to…
A: EXPLANATION - Firstly declare variables that are used in program . Then take input from user about…
Q: 4. Write pseudo code that will perform the following. a) Read in 5 separate numbers and calculate…
A: Required:
Q: Q6: Write a program to find and print the value of (f) from the following equations for Fourteen…
A: The elif keyword is pythons way of saying if the previous conditions were not true then try this…
Q: 11. Simplify the following statement. i) (p^¬g) v (p^9) ii) (p V¬q) ^(¬p V ¬q)
A: We can simplify the both statement are as follows:
Q: 5) int x; x=10,20,30; cout<<x<<endl;
A: Coded using C++.
Q: 4.18 LAB: Input and formatted output: House real estate summary Sites like Zillow get input about…
A: current_price=int(input())last_month_price=int(input())mortgage = (current_price *…
Q: int i, j; for(i=3, j=4 ; i>10; --i,j--) { } printf("%d and %d", i, j);
A:
Q: int [] X = {12,15,12}; int [] Y = {1,2,3}; int i=0; for(int a:X) { if(a%2==1) { Y[i]=a; i++; } %3D
A: In the above question, we have to print the output of the given program. In this there are two…
Q: HW: Q5: Write a program to calculate the B power of Afor now-aegative value of B. 4sAxAra.x4 Wilhout…
A: NOTE: We’ll answer the first question since the exact one wasn’t specified. Please submit a new…
Q: 13. Write a program that reads in two integers and determines and prints if the first is a factorial…
A: Required: A program to read two integers and check if the first is a factorial of the second or not.…
Q: Q1) Write a program to add 3 numbers ( 2 bytes each), The 1" one is stored in memory locations…
A: Write a program to add 3 numbers two bytes each.
Q: 12. Write a program to sort the string “ougojxpvrkoawwja" in ascending (increasing) order.
A: While doing programming in any programming language, you need to use various variables to store…
Q: 49- Find the output of the following program. * main(){ int a = 10, b, c; b = a++; C = a; cout << a…
A: The given code is - main(){ int a = 10, b, c; b = a++; c = a; cout << a << "…
Q: 49- Find the output of the following program. main(){ int a 10, b, с; = a++; C = a; cout << a <« “ «…
A: int a=10,b,c; means a=10 and a=b means b=10 and a=c means c=10
Q: Q3 Let U = {5, 6 }, write an equivalent to the following assertions: 3x P ( x ) v - Vx Q ( x )
A: The answer is below:
Q: 3.19 LAB: Exact change Write a program with total change amount in pennies as an integer input, and…
A: Program: The program contains the set of instructions that are used to perform certain activities.…
Q: Q4: Write a program to sort the following list of numbers ascendingly. L=[15,6,8,19,10,17,7,22,5,14]
A: As you have not mentioned the coding language i am providing the solution in java: Code: public…
Q: 10. a) *Write a program to multiply ex6398 with ex1DFE and store the result in R10. b) What are the…
A: Part A) MOV R0, #0x6398 MOV R1, #0x1DFE MUL R2, R0,R1 STR R2, [R10]
Q: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The…
A: The below given C++ program code will obey the following rubrics: Including necessary header files.…
Q: 4 using namespace std; 6 int main() 7 { cout » euro; 14 cout « endl; 15 // Prompt user and read in a…
A: #include<string>using namespace std; int main(){ cout<<"Dollar to Euro Currency…
Q: 6.12) Since communications channels are often noisy, numerous ways have been devised to ensure…
A: the code is given below in c
Q: Q.5/ Write a program to enter two numbers and compute multiplication and division operations using…
A: Dim x, y, z As Single ' Description: Compute Multiplication & Division operationPrivate Sub…
Q: 4. Using the machine language introduced in the class, write a program that multiplies the numbers…
A: program of multiplication of matricies:
Q: 3.39 The computer game function collision() checks whether two circular objects col- lide; it…
A: To find collision of two circles we calculate distance between two centers and sum of two radius…
Q: Python 3.7.4: The current calendar, called the Gregorian calendar, was introduced in 1582. Every…
A: Create three functions in the program first is taking input from a user, second is checking whether…
Q: Searching for Substrings
A: Program structure Includes header file <stdio.h> for input/output operations and…
Q: QUESTION 18 Int xt 200, int yt 100 Int dt, d2 mov EAX, x1: mov EBX, yt: push EBX pop ECX mov d2, ECX…
A: The register EAX,EBX,ECX are data register ,it is used to store the value . The answer is 18)100…
Q: 27- The modulus operator uses character. * % 49- Find the output of the following program. main(){…
A: Note:- as per our guidelines only 3 mcqs are allowed to answer. Please repost last one. Modulus…
Q: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The…
A: Remember, indentation is an important factor in python. So we have to maintain that. Code:…
Q: 7. Let the statements A, B be given by A: not(p or q), B: (not p) or q. Let T= true, F = false. If p…
A: Given , A: not( p or q ) ; p = T ; q = F . i.e A = not ( T or F ) A = not ( T ) A = F
Q: Q6: Write a program to find and print the value of (f) from the following equations for Fourteen…
A: Since the values aren't given with the question, we write the program to find f for any values of…
Q: 15. What is the output, if any, of the following C/C++ code? int a[5]=(3,4,5,6,7}; int…
A: Option a is syntax error because of main.c: In function ‘main’: main.c:9:13: warning: initialization…
Q: 50- Find the output of the following program. main(){ int a, b = 10; a = 95 / 10; cout << a << endl;…
A: Given data: 50: main() { int a, b = 10; a = 95 / 10; cout << a << endl;} 2:…
Q: Python 3.7.4: The current calendar, called the Gregorian calendar, was introduced in 1582. Every…
A: In order to correct given program, make the following changes:Put def main() code above the def…
Q: 7.14 LAB: Remove all non-alpha characters Write a program that removes all non-alpha characters from…
A: Please find the answer below :
Q: 4.1 Complete the C function given below: void next10odd(int n){ //print the next 10 consecutive odd…
A: 1) Below is program that define function next10odd which print the next 10 conscutive off integers…
Q: Python 3.7.4: Write a loop that reads positive integers from standard input and that terminates when…
A: Following is the program code that takes input from the user all positive integer and terminates if…
Q: 14- The following script is used to find the series (g = 1+ e-x+2e-2x + 3e-3x + + 10e-10x) *…
A: The answer is false, because the above mentioned code generates the following error.
Q: Q6: Write a program to find and print the value of (f) from the following cquations for Fourteen…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Read the value of θ…
Q: 6. (18) Write a Java program (18 = 3(a) + 2(b) + 3(c) + 3(d) + 3(e) + 4(f) a. Define 2 String…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: 2. Write a program to find the Greatest Common Divisor (GCD) of two numbers.
A: Here I have defined the function named gcd(). This function takes 2 numbers as input parameters and…
Q: b In multiplication, assume that leading zeroes are not allowed. Write a program in C++ to help…
A: Required: In multiplication, assume that leading zeroes are not allowed. Write a program in C++ to…
Q: 14- The following script is used to find the series (g = 1+ e-x+2e-2x + 3e-3x + ..• + 10e-10x) *…
A: Task : The task is to check whether the given code implements that series whose value is equal to…
Q: 24. What will the following code print out def func(x): print (x) func (10) func (20) b. func 10 d.…
A: Python is a very famous programming language these days, It is an Object oriented programming,…
Q: 8- The output of the following program is:- * DO 111 M= 1 , 2 DO 122 J=1,6,2 122 CONTINUE PRINT*, M…
A: Given question has asked to print the output of given FORTRAN codes:- Code1 DO 111 M = 1,2DO 122 J…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Python programming-basics homework assignment: Write a program that inputs a text file, should print unique words in file in abc order, uppercase words should take precedence over lower. this is example of output: example text file: brown dog fox jumps lazy over quick the example output: brown dog fox jumps lazy over quick the THis is MY output: thequickbrownfoxjumpsoverthelazydog This is my code: QUESTION: why it won't SORT or removing unique text like example output: # Put your code herefileName = input("Enter the input file name:")word_list = []with open(fileName) as words: for line in words: line.rstrip() for list_of_words in line.split(): print(list_of_words) word_list.sort() for list2_words in word_list: if list2_words not in word_list: word_list.sort() word_list.append(list_of_words) for new_words in line.split(): print(new_words)#include <iostream> #include <bits/stdc++.h> #include <chrono> #include <stdlib.h> #include <cstdlib> #ifdef _WIN32 #include <Windows.h> #else #include <unistd.h> #endif using namespace std; void shuffle(string cardTyperr[], int n) { unsigned seed = chrono::system_clock::now().time_since_epoch().count(); shuffle(cardTyperr, cardTyperr + n, default_random_engine(seed)); for (int i = 0; i < n; ++i) cout << cardTyperr[i] << " "; cout << endl; cout << flush; system ("CLS"); } void playerScore(string playerName[]) { int player1 = 0; int player2 = 0; cout << "Score for PLAYER 1: " << player1 << endl; cout << "Score for PLAYER 2: " << player2 << endl; } int main() { string playerName[2] = {"PLAYER 1", "PLAYER 2"}; int cardOrder[8] = {0, 1, 2, 3, 4, 5, 6, 7}; for (int i = 0; i < 8; i++) { cout << cardOrder[i] << " "; } cout << endl; string cardType[8] =…Exercise Fibonacci (Overflow): Write a program called FibonacciInt to list all the Fibonacci numbers, which can be expressed as an int (i.e., 32-bit signed integer in the range of [-2147483648, 2147483647]). The output shall look like: F(0) = 1 F(1) = 1 F(2) = 2 ... F(45) = 1836311903 F(46) is out of the range of int Hints: The maximum 32-bit int is kept in constant Integer.MAX_VALUE. You cannot use F(n-1) + F(n-2) > Integer.MAX_VALUE to check for overflow. Instead, overflow occurs for F(n) if (Integer.MAX_VALUE – F(n-1)) < F(n-2), i.e., no room for the next number. Try: Write a similar program for Tribonacci numbers. Exercise NumberConversion: Write a method call toRadix() which converts a positive integer from one radix into another. The method has the following header: public static String toRadix(String in, int inRadix, int outRadix) // The input and output are treated as String. Write a program called NumberConversion, which prompts the user for an input number, an input…
- given ASCIIOFSET .FILL x0030 NegASCIIOFSET .FILL xFFD0 ASCIINewline .FILL x000d ; Newline ascii code ASCIISpace .FILL x0020 ; Space ascii code ASCIIComma .FILL x002C ; Comma ascii code Use LC-3 I/O device to print number, commas, and spaces in printCommaSpace subroutine, also check code to see if it follows instructions and modify accordinglyWrite a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum=40: 10 5 2 import java.util.Scanner; public class DivideByTwoLoop {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);int userNum; userNum = scnr.nextInt(); while (userNum>1 && userNum<-1) { //the bolded part is the part I tried and I need help with that//userNum=userNum/2;System.out.print(userNum*2);} System.out.println("");}} 1// Task 2 // For this function, you must build a string that when printed,// will output the entire binary representation of the integer x,// no matter how many bits an integer is. You may NOT use// division (/) or mod (%) anywhere in your code, and should// instead rely on bitwise operations to read the underlying binary// representation of x.stringbuilder get_bin_1(int x) { stringbuilder sb = new_sb(); sb_append(sb, '$'); return sb;}
- Caesars Cypher in C programming language How do you program an encryption and decryption for a Caesars Cypher that covers all the possible ASCII characters? In this there should be a shift over K = 5 but the example below is K = 3. This should result in actual character and not the control ASCII represenations. For example: >>> $ encrypt(I have a key)N%mf{j%f%pj~>>> $ encrypt(see me at 3)xjj%rj%fy%8>>> $ decrpyt(|jfw%ns%gqzj)wear in blue Assume that the text parsing method has been succesful and it's the encryption/decryption of the char array that needs to be factored. Formula Encryption -> C = E(k, P) = (P + k) (mod 26) Decryption -> P = D(k, C) = (C - k) (mod 26) Where k = 5Trace the following Code and then print the output. msg db 'hello world$' newline db 10,13,'$' buffer db 10 dup mov ah,9 mov dx,offset msg int 21h ;new line mov ah,9 mov dx, offset newline int 21h ;enter a string from the keyboard lea dx,buffer mov ah,0ah int 21h ;new line mov ah,9 mov dx,offset newline int 21h ;adding the $ symbol at the end of the string mov bx,0 mov bl,buffer[1] mov buffer[bx+2],'$' mov ah,9 mov dx,offset buffer+2 int 21hpython: Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line:From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a count at the end. Hint: make sure not to include the lines that start with 'From:'. Also look at the last line of the sample output to see how to print the count. You can download the sample data at http://www.py4e.com/code3/mbox-short.txt my code: fname = input("Enter file name: ")if len(fname) < 1: fname = "mbox-short.txt" fh = open(fname)count = 0 print("There were", count, "lines in the file with From as the first word")
- 4. In IntelliJ: By using java code a) Turn the For loop into a loop that adds the numbers from 50 to 1 and execute it. b) Turn the While loop into a loop that adds the numbers from 1 to 50, but does not add the number 25, and execute it. c) Turn the Do-while loop into a loop that add all numbers from 50 to 1, but does not add neither number 25, 27 and 37, excute itU={A,B,C,D,E,F}, A={A,B,D,E}, B={B,C,E,F}, and C={A,B,C,D} complete the following set operations: 1(A'n B) uC' 2. A n (Bu C;)Q12,. A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome..