TRENDING NEWS

POPULAR NEWS

Write A C Program That Display The Reverse Of String By Stack

"write a program in 8086 assembly language that reverse a string using stack. the string can be assumed to be

I'd save the stack pointer, just push everything to the stack, then copy that to the new string location, then reset the stack point to the original postion.

But that's me.

How can I write the output of the program where a string will be changed from"My name is Robert" to "yM eman si treboR"?

Solution is actually harder than you think if you’re an overthinker like myself and have to think about “what if I had a more complex string?”.You start with a string as an inputYou split the string into chunks or arrays or whatever you wanna call em for punctuation so with “.“ and “,” etcLets call these chunks ‘sentences’You trim each sentence to leave out excess spaces on the beginnings and ends of every sentence part.Then you split every sentence part into words by splitting with “ “You reverse the order of each word using some fancy shmancy algorithm. It’s basically just shifting around characters in the string.You reconcatenate the reversed words back into sentences using a space before each word.You put the reversed word sentences together putting a period between every sentence.Fix the bugs you eventually made writing itProfit???It gets harder adding more punctuation into it. This is actually a good project for beginner programmers

How can I write a C++ program to reverse words of a string individually. For example if "I love coding" is given then print is "I evol gnidoc"?

#include
#include
using namespace std;
int main()
{
int i=0,j=0,k=0,l=0;
char x[14]= "I LOVE CODING";
char y[14]={'\0'};
for(i=0;i<=14;i++)
{
if(x[i]==' ' || x[i]=='\0')
{
for(j=i-1;j>=l;j--)
y[k++]=x[j];
y[k++]=' ';
l=i+1;
}
}
cout< return 0;
}
I hope this helps.Happy Coding :)

C++ Experts : Write a function reverseQ that uses a local stack to reverse the contents of a queue.?

is it going to take another 15 years before people stop misusing the words "Standard Template Library"? While there was a stack class defined in STL back in the early 90s, these days people use the stack class defined in the C++ standard library (standard containers library, to be specific).

Assuming your queueType has front(), push(), pop(), and empty() (like std::queue), your function could go like this:
     std::stack s;
     while(!q.empty()) { s.push(q.front()); q.pop(); }
     while(!s.empty()) { q.push(s.top()); s.pop(); }

Write a program reverse.c that echoes its commandline arguments in reverse order. Running the program by typin?

You should start going to class.

I won't give you the answer but here are some good clues:
- with main(int argc, char **argv), argc will be the count and argv the list of string pointers for each argument
- argv[0] is the program name so you'll want to skip it
- you could use a for loop starting at argc - 1 and ending at 1 to output the word with printf()

Print the reverse of a string in assembly language?

I am writing a segment of the code :

; read a character
Mov ah,1
Int 21h

While_:
CMP AL,0dh ; 0dh means ascii character of carriage return,CR?
JE END _WHILE ; yes , exit loop

; or push characters in stack

END _WHILE:
;go to new line

MOV AH,2 ; display char func
MOV DL,0dh ;CR
INT 21h ; execute
MOV DL,0ah ;LF =line feed or new line
INT 21h; execute
JCXZ exit ; exit if no characters is read

; else pop from stack in a loop

Suppose I am printing a string: ”This is a test” and reverse : tset a si sihT

1. How do I go back to current string‘s start “This is a test” while taking characters? (CMPAL,0dh , what does this mean ?)Does carriage return (CMPAL,0dh)mean pressing the enter key?
2. If CMP AL, 0dh means pressing the enter key then what is the need of line feed (new line) ? What does MOV DL,0ah mean ?

Please explain

How do you reverse a string, using the stack data structure in Python?

def rev_string_using_stack(string):
rev_str_st = Stack()
# push all characters into stack.
for c in string:
rev_str_st.push(c)

# Build a new reverse string and return it
rev_str = ""
while rev_str_st.size():
rev_str += rev_str_st.pop()
return rev_str

print (rev_string_using_stack("ult pult"))

TRENDING NEWS