answersLogoWhite

0


Best Answer

// get input

char input[256];

gets(input);

// print one character on each line

int i;

for(i = 0; input[i] != '\0'; ++i) {

printf("%c\n", input[i]);

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: To display an input string vertically by c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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 to write a C plus plus Program to convert a string into an integer?

std::string input = ""; std::getline (std::cin, input); // get input from stdin std::stringstream ss (input); // place input in a string stream integer num = 0; if (ss >> num) // extract integer from string stream { // Success! } else { // Fail! }


A c comma c plus plus program that can accept first name surname and display it?

int main() { std::string first, last; std::cout << "Enter your first name: "; std::cin >> first; std::cout << "Enter your last name: "; std::cin >> last; }


C program asking to enter string?

its simple in c and c++: mainly it depends on what type of answer ur looking track fro the user .. if its a numeric u can define a integer or float variable else a string variable to store characters . ex : printf("\n whats ur age ?"); scanf("%d",&age); printf("\n hey ur %d years old :",age); cout


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<iostream> #include<sstream> int main() { std::cout << "Input:\t"; std::string input = ""; std::getline (std::cin, input); if (input.size()) { std::cout << "Output:\t"; unsigned index = input.size() / 2 * 2; do { index -= 2; std::cout << input[index]; } while (index); std::cout << std::endl; } }

Related questions

Determine the highest of the three input numbers using flowchart?

(start) /a=0 c=0\ \b=0 / /input a/ /input b/ /input c/ /a>b\ no /b>c\ yes /display b/ -> (a) \ / \ / yes no /a>c\ no /display c/ -> (a) \ / yes /display a/ <- (a) (end)


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 to write a C plus plus Program to convert a string into an integer?

std::string input = ""; std::getline (std::cin, input); // get input from stdin std::stringstream ss (input); // place input in a string stream integer num = 0; if (ss >> num) // extract integer from string stream { // Success! } else { // Fail! }


A c comma c plus plus program that can accept first name surname and display it?

int main() { std::string first, last; std::cout << "Enter your first name: "; std::cin >> first; std::cout << "Enter your last name: "; std::cin >> last; }


How do you input a string in c?

just use fgets() from file stdio.h (not gets: it is security hole)


How can you read string in C language?

You mean read from file/standard input? With function fgets.


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

#include<stdio.h> #include<conio.h> void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i<=19) { scanf("%c",&string[i]); i++; } while(i>=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<stdio.h> #include<conio.h> #include<string.h> void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length>0) { printf("%c",string[length]); length--; } getch(); }


C program asking to enter string?

its simple in c and c++: mainly it depends on what type of answer ur looking track fro the user .. if its a numeric u can define a integer or float variable else a string variable to store characters . ex : printf("\n whats ur age ?"); scanf("%d",&age); printf("\n hey ur %d years old :",age); cout


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<iostream> #include<sstream> int main() { std::cout << "Input:\t"; std::string input = ""; std::getline (std::cin, input); if (input.size()) { std::cout << "Output:\t"; unsigned index = input.size() / 2 * 2; do { index -= 2; std::cout << input[index]; } while (index); std::cout << std::endl; } }


Write a C program to accept a string from user and display its ascii value and then display sum of all ascii value of strings?

//C program to accept a string from user and //display its ascii value and //then display sum of all ascii value of strings #include<stdio.h> #include <string.h> int main() { char String[100]; int Sum,Index; Sum=0; //Sum is initially zero printf("Enter the string:\n"); gets(String); //Accept String from User for(Index=0;Index<strlen(String);Index++) { Sum+=(String[Index]); //Adds (the ASCII values of) the String characters. } printf("The sum is %d\n",Sum); //Printing it as %d gives the equivalent ASCII value. return 0; }


How do you write a c plus plus program to display n congratulatory messages where n is a user input value?

#include<iostream> #include<sstream> int main() { unsigned num; while (true) { std::cout << "Enter a number: "; std::string input; std::cin >> input; std::stringstream ss; ss << input; if (ss>>num) break; std::cerr << "Invalid input.\n"; } for (int i=0; i<num; ++i) std::cout << "Well done!\n"; }


A C program to print the number of words from given String?

/*We can calculate this with a lot of methods I'll explain only one of them */ *str = "abcd"; // this is a input string printf("%d", strlen(str));