Monday, 9 November 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:-


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment