Write an algorithm that receives a string and reverses it.
Answers were Sorted based on User's Feedback
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 |
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 |
Complexity T(n) What is the time complexity T(n) of the following portions of code? For simplicity, you may assume that n is a power of 2. That is, n = 2k for some positive integer k. a) ? for (i = 1; i <= n; i++) { j = n; cout << i << ? ? j << ? ? << endl; } b) ? for (i = 0; i <= n; i += 2) { j = n; cout << i << ? ? j << ? ? << endl; } c) ? for (i = n; i >= 1; i = i/2) { j = n; cout << i << ? ? j << ? ? << endl; } d) for (i = 1; i <= n; i++) { j = n; while (j >= 0) { cout << i << ? ? j << ? ? << endl; j = j - 2; } }
Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
0 Answers ASD Lab, Qatar University, UNV,
Hello, I am trying to write a program in c++ which accepts month and year from the user and prints the calender. So please tell me the algorithm and what is the calender logic.
Assume in University Every student in university as entity, prepare a class for student that store the roll no, name, dob of student, and make funtion of deletion, manipulation, addition of student record.
1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
0 Answers Jomo Kenyatta University,
write a program that accepts a number and outputs its equivalent in words. take note that the maximum input is 3000
void main() { int i,j=2; for(i=0;i<3;i++) if(j=i) cout<<"Lotus "; else cout<<"Rose "; } Its result is Rose Lotus Lotus.. How? Explain it?
Display Pattern: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …
write a function – oriented program that calculates the sum of the squares from 1 to n. thus, if the input is 3, the output is 14