اكواد في لغة c++ تخص السترينغ string

تحويل السترينغ الى كبير اذا كان صغير وبالعكس
#include<iostream.h>
#include<ctype.h>
void main( )
{
char s [ ]="abCDefGH ";
cout << s << endl;
for ( int i =0; i < 8; i++ )
if (s [i]>=65&&s [i]<=90)
s [i] = char(tolower (s[i] ));
else
  s [i] = char(toupper (s[i] ));
cout << s;
}
تحويل السترينغ from small to capital abcd =ABCD
#include<iostream.h>
#include<ctype.h>
void main( )
{
char s [ ] = "abcd";
cout << s << endl;
for ( int i =0; i < 4; i++ )
s [i] = char(toupper (s[i] ));
cout << s;
}
Swapping of strings using c++ programming language
#include<iostream.h>
#include<string.h>
#include<cstring.h>
#include<ctype.h>
#include<stdio.h>
int main(){
  int i=0,j=0,k=0;
  char str1[20],str2[20],temp[20];
  puts("Enter first string");
  gets(str1);
  puts("Enter second string");
  gets(str2);
  puts(str1);
  puts(str2);
  while(str1[i]!='\0'){
temp[j++]=str1[i++];
  }
  temp[j]='\0';
  i=0,j=0;
  while(str2[i]!='\0'){
  str1[j++]=str2[i++];
  }
  str1[j]='\0';
  i=0,j=0;
  while(temp[i]!='\0'){
  str2[j++]=temp[i++];
  }
  str2[j]='\0';
  puts(str1);
  puts(str2);
  return 0;
}
BCDA طباعة السترينغ عكسي
#include<iostream.h>
void main( )
{
char s [ ] ="ABCD";
cout << "Your String is: " << s << endl;
for ( int i =3; i >= 0; i-- )
cout << "S[" << i << "] is: " << s [ i ] << endl;
}
اكواد في لغة c++ تخص السترينغ string Reviewed by حامد طالب العراقي on 5/13/2015 04:38:00 م Rating: 5

ليست هناك تعليقات:

نموذج الاتصال

الاسم

بريد إلكتروني *

رسالة *

يتم التشغيل بواسطة Blogger.