Write an algorithm that receives a string and reverses it.

Answers were Sorted based on User's Feedback



Write an algorithm that receives a string and reverses it...

Answer / sreejesh1987

step 1:Declare the variables needed.
step 2: Get the String in a String variable
step 2:Use a for loop to reverse the string.
step 3:Display the elements of the string from last element
to first element.

Is This Answer Correct ?    5 Yes 0 No

Write an algorithm that receives a string and reverses it...

Answer / sudip chatterjee

1. Start.
2. Declare Array str1[25], str2[25] as an alphanumeric.
3. Declare i, g, l, as numeric.
4. Assign or accept value to Str1.
5. l=i=0;
6. while(str1[i]!="/0")["/0"last index point that u entered.]
a.increase i, l by 1;
7. Repeat steps i,ii, iii for j from o
i. str2[j]= str1[i-1]
ii. increase j by 1.
iii. decrease i by 1.
8. str2[j]="/0" .
9. Display str2
10. Exit.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C++ Code Interview Questions

Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

3 Answers   Nagarro,


write a program that reverses the input number of n.Formulate an equation to come up with the answer.

0 Answers   Satyam,


How reader and writer problem was implemented and come up with effective solution for reader and writer problem in case we have n readers and 1 writer.

6 Answers   Microsoft, NetApp,


What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }

3 Answers   CTS, IBM, Infosys, Qatar University,


how to write a program that opens a file and display in reverse order?

0 Answers   SMC,






1+1/2!+1/3!+...+1/n!

0 Answers  


Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!

1 Answers   Motorola, Qatar University,


Where now stands that small knot of villages known as the Endians, a mighty forest once stood. Indeed, legand has it that you could have stoodon the edge of the wood and seen it stretch out for miles, were it not for the trees getting in the way. In one section of the forest, the trees stood in a row and were of hight from 1 to n, each hight occurring once and once only. A tree was only visible if there were no higher trees before it in the row. For example, if the heights were 324165, the only visible trees would have been those of height 3,4 & 6. Write a Program that takes an array of integers representing the heights of the trees in the row as input and prints the list of the visible trees.

2 Answers   ABC, Nagarro,


Write A C++ Program To Input A Number Between 20 To 99 And Display Its Numbername?

3 Answers   TCS,


write a program that calculate the volume of cylinder after user enters radius and height and show the algorithm used

1 Answers   Jomo Kenyatta University,


Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

3 Answers   TCS, Vimukti Technologies, Wipro,


can you please write a program for deadlock that can detect deadlock and to prevent deadlock.

0 Answers  


Categories