After the following code executes, to what will the character string x be equal?
#include <iostream>
int main()
{
char x[20] = "Hello World";
char y[20];
__asm
{
cld;
lea EDI, x;
mov ecx, 5;
mov al,60
rep stosb;
nop
}
}
Answer: Hello
Explanation: rep movsb; will move ecx bytes which is 5 from the string x
After the following code executes, to what will the character string x be equal? #include <iostream>...
#include "stdio.h" #include <iostream> int main() { unsigned char var1 = 4; unsigned short int var2 = 255; unsigned short int var3 = 16; unsigned int var4 = 1; asm_ MOV AL, var1; MOV AX, var2; MOV AX, var3; MOV EBX, var4; MOVZX ECX, AX; What is the hexadecimal value of BX?
6. What will be the final value in EDX after this code executes? mov edx, 1 mov eax,7FFFh cmp eax,0FFFF8000h jl L2 mov edx,0 し2: 7. (True/False): The following code will jump to the label named Target. mov eax,-30 cmp eax,-50 ig Target 8. Implement the following pseudocode in assembly language. Use short-circuit evaluation and assume that vall and X are 32-bit variables. if vall >ecx ) AND (ecx> edx) X=1 else X=2;
what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...
#include <iostream> #include <stack> #include <queue> using namespace std; void printFromStack(string expr){ stack<char> myStack; for(int i=0; i<expr.length(); i++){ //Insert code here to push each character onto the stack } cout << "My stack is popped in this order" << endl; while(!myStack.empty()){ //Insert code here to cout the top of the stack one by one //Pop each one after it’s printed out } cout << endl; } void printFromQueue(string expr){ queue<char> myQueue; //Insert code here to push each character onto the...
Fix the following code to print whether the input is positive or negative #include <iostream> #include <string> using namespace std; void positiveOrNegative(int); // declare function int main(){ int y; int result; cin >> y; result = positiveOrNegative(y); return 0; } void positiveOrNegative(int x){ if (x>=0) cout << "Positive"; else cout << "Negative"; }
C++
language
utput after the code executes on that data set. Assume the input file opens successfully. #include <fstream> #include «iostream> using namespace std; int main ) int n = 0; int m-0; double d 0.0; char c = '*' , ifstream fin; fin.open ("data.txt"): fin >>n >> m>>c>>d; return 0; 7. Data set: 57 2.5 Output Data set: 5 2.57 Output: Data set: 5 7 2.5 Output . Data set: 57 2.5 * Output:
#include <cstring> // for strlen() #include <cassert> // for assert() #include <iostream> // for cout using namespace std; class MyString { private: char *m_data; int m_length; public: MyString(const char *source = "") { assert(source); // make sure source isn't a null string // Find the length of the string // Plus one character for a terminator ...
X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code INCLUDE Irvine32.inc .data KeyPrompt BYTE "Enter the passphrase: ",0 TextPrompt BYTE "Enter the plaintest: ",0 str1 BYTE "The passphrase has length:",0 str2 BYTE "The plaintest has length:",0 KeyIs BYTE "The passphrase: ",0 PlainTextIs BYTE "The plaintext: ",0 CipherTextIs BYTE "The ciphertext: ",0 KMAX = 64 ; passphrase buffer maximum size BMAX = 128 ; test...
#include <iostream>
#include <string>
using namespace std;
void get_user_string(string *);
string convert_to_dash(String* );
int_search_and_replace(char, string, string
&);
int main (){
string s;
cout << "Enter a string:" << endl;
get_user_string(&s);
string dash_version =
convert_to_dash(&s)
if ( dash_version != 32){
&s.push_back('-');
}
Here is an example operation of the completed program: Please enter a string: the weather is great! The dash-version of your string is: Please tell me the char that...