answersLogoWhite

0


Best Answer

#include<string>

#include<iostream>

std::ostream& alternate (std::ostream& os, const std::string& str) {

for (size_t index=0; index<str.size(); index+=2) os << str[index];

return os;

}

int main (void) {

std::string test {"The quick brown fox jumps over the lazy dog"};

alternate (std::cout, test);

std::cout << std::endl;

}

Output:

Teqikbonfxjmsoe h aydg

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a output of a program to input string and to print the alternate characters?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Are spaces taken as single character in a string?

public class count { public static void main(String[] args) { String string = "1 2 3 4"; char[] array = string.toCharArray(); System.out.println("Number of characters in string: " + string.length()); System.out.println("Number of characters in array: " + array.length); } } Output: Number of characters in string: 7 Number of characters in array: 7 So yes, spaces are taken as single characters in a string.


Write a program to eliminate the blanks from string 8085?

public class RemoveSpace{ public static void main(String args[]){ String str = "8085"; Sysytem.out.println(str.trim()); } } Get The Desired OutPut....


A program of c plus plus to accept the string and display the alternate characters in reverse order using pointer?

The following program prints every second character of the input in reverse order. #include&lt;iostream&gt; #include&lt;sstream&gt; int main() { std::cout &lt;&lt; "Input:\t"; std::string input = ""; std::getline (std::cin, input); if (input.size()) { std::cout &lt;&lt; "Output:\t"; unsigned index = input.size() / 2 * 2; do { index -= 2; std::cout &lt;&lt; input[index]; } while (index); std::cout &lt;&lt; std::endl; } }


How do you use MID function in qbasic?

...QBASIC program code... name$="Jack" startCharPos%=2 howManyChars%=2 PRINT MID$(name$,startCharPos%,howManyChars%) ...output... ac EXPLANATION The MID$() function allows you to select characters from out of a string. In the above case the string is,... name$="Jack" ...where... J= string position 1 a= string position 2 c= string position 3 k= string position 4 ...thus, if we select MID$(name$,2,2)... ...this code is actually saying...select from the name...the character which begins at position 2 = a/and, extract 2 characters going along from there... = ac.


Write a java program to pass a string have a good day from command line?

public class HaveAGoodDay { public static void main(String[] args) { for (final String arg : args){ System.out.print(arg +" "); } } } compile and run the program: java HaveAGoodDay have a good day. output: have a good day.


How do you display a text reversely in C language without using onlu simply input and output?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i&lt;=19) { scanf("%c",&amp;string[i]); i++; } while(i&gt;=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;string.h&gt; void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length&gt;0) { printf("%c",string[length]); length--; } getch(); }


Is java's println a method?

Consider the following statement: System.out.println ("string to be printed"); The statement begins with System.out. This is a constant that represents the default output mode, which in this case is the screen. The constant helps to read and display the data in a Java program. The output is generated using the built-in println() method. The string that is assigned to the println() method is displayed when the statement is executed. For example, class Class2 { public static void main (String args[]) { System.out.println("Here is your string"); } } The above program will show the following output: Here is your string


What elements are in string?

A string is an array of characters.


How do you Print all the first characters in the string in python programming?

Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!


Count characters in an input string using c sharp?

Console.WriteLine("Please input a string:"); string str = Console.ReadLine(); Console.WriteLine("Number of characters: " + str.Length);


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


How do you count the number of words in a string?

To find the length of the string we use length method. The length property returns the length of a string (number of characters we use).The length of an empty string is 0. For example: function myFunction() { var str = &quot;Hello World!&quot;; var n = str.length; Hope this hepls.