09/11/2015

C++ Program To Print A String

Problem:- Write A C++ Program To Print A Full String Input By Keyboard or how to print a string in c++ using cout or print string in c++ using printf or how to output a string in c or cout string array c++ or write a c++ program that displays your name on the output screen or input string in c++ or string manipulation in c++ program or string in c++ example or output string c++ or cout string array c++ or print string in c++ using printf or how to output a string in c or c++ string << operator or c++ cout example or c++ operator to string or how to print quotation marks in c++.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Logic:- Take an input and using a " For Loop " print string in screen this is a very simple program just like a print a Hello World!.  In this program I use a gets() function this is why we can take an input included with space or in other words we can say that we can take a sentence as in input. For next level, after this problem, you can check this problem and practice See the problem C++ Program To Display String From Backward 


Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.

Solution:-


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
/*Visit - www.programmingwithbasics.com*/
   
    cout<<"=====================================";
    cout<<"\nVisit - www.programmingwithbasics.com";
    cout<<"\n=====================================";
    
  char a[20];
  int i,j;

  cout<<"\n\nEnter The String: ";
  gets(a);  
  cout<<"\n\nYour Entered String is Given Below \n\n";

  for(i=0;a[i]!='\0';++i)
  {
  cout<<a[i];
}
return 0;
}

Output:-


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: