Program to illustrates String

/*  Program to illustrates String */
#include <iostream.h>
#include <conio.h>
void main( )
{
char str[ ] = "Hello";
 int i = 0;
 while (i<=4)
{
          cout << str[i];
           i++;
}
getch( );
}
------------------------------------------------

/*  Program to illustrates String */
#include <iostream.h>
#include <conio.h>
void main( )
{
char str[ ] = "Hello";
 int i = 0;
 while (str[i]!='\0')
{
          cout << str[i];
           i++;
}
getch( );
}
-----------------------------------------------

/*  Program to illustrates String */
#include <iostream.h>
#include <conio.h>
void main( )
{
 char str[ ] = "Hello";
 char *ptr ;
 ptr = str;                       //store base address of string
 while (*ptr !='\0')
{
      cout << *ptr;
       ptr++;
}
getch( );
}
---------------------------------------------------
/*  Program to illustrates String */
#include <iostream.h>
#include <conio.h>
void main( )
{
 char str[] = "Hello";
                           cout<<str;
           getch( );
}
------------------------------------------
/*  Program to illustrates String */
#include <iostream.h>
#include <conio.h>
void main( )
{
char str[20] ;
cout<<"\n Enter any string :";
cin>>str;
cout<<"\n The string is  :"<<str;
getch( );
}





0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|