0% found this document useful (0 votes)
459 views4 pages

C++ String Arabic

This document explains how to use string in C++ programming language. هذا الملف يوضح كيفية استخدام سلاسل الحروف بلغة C++ باللغة العربية مع الأمثلة..

Uploaded by

Houmam WAZZEH
Copyright
© Public Domain
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
459 views4 pages

C++ String Arabic

This document explains how to use string in C++ programming language. هذا الملف يوضح كيفية استخدام سلاسل الحروف بلغة C++ باللغة العربية مع الأمثلة..

Uploaded by

Houmam WAZZEH
Copyright
© Public Domain
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4

2nd TERM

HIAST - C++ - 2nd Year

February 6, 2012

DOC
1


char
ASCII

.1Byte

char

:
:iomanip setw

setiosflags

) :setw(n ) (

n ..

) (
:
''a' < 'b
''A' + 5 < 'H

''A' < 'a


''a' + 2 == 'c

) :setiosflags(ios::left
) (setw
.

>#include <iostream
>#include <iomanip
;using namespace std

)(int main
{
;'char a = 'a
;'char A = 'A

;"cout << "\n


;"cout << " a = " << (int)a << " , A = " << (int)A << "\n
;"cout << "\n
;"====================== cout << " ASCII table for [a-z]:\n
)for (int i = 0; i < 26; i++
{
;" if(i % 6 == 0) cout << "\n
" = " << )cout << (char)(a + i
;)<< setw(6) << setiosflags(ios::left) << (a + i
}
;"cout << "\n\n
;"====================== cout << " ASCII table for [A-Z]:\n
)for (int i = 0; i < 26; i++
{
;" if(i % 6 == 0) cout << "\n
" = " << )cout << (char)(A + i
;)<< setw(6) << setiosflags(ios::left) << (A + i
}
;"cout << "\n\n
;)"system("pause
;return 0
}

Eng. M.Houmam Wazzeh | 0988047201 | Monday, February 06, 2012


[email protected]

char

:char
'\0'
#inc
clude <iost
tream>
usin
ng namespac
ce std;
fine MAX_SI
IZE 30
#def

// const
tant

ength(char str[]);
int get_str_le
d convert_t
to_upper(char str[]);
void
void
d convert_t
to_lower(char str[]);

300 str

:
29
.'\0'


:
cin
.cinn

int main()
{
r[MAX_SIZE];
/*char str
cout << "\
\n";
cout << " # Enter a string(max 29 charact
ter): ";
r;
cin >> str
cout << "\
\n";*/
//char str
r[] = "Hello Students!!\n >> Tod
day is:
char str[]
] = {
'H', 'e', 'l',
'e', 'n', 't',
' ', 'T', 'o',
' ', 'M', 'o',
'e', 'b', 'r',
'6', ',', ' ',
};

'l',
's',
'd',
'n',
'u',
'2',

'o',
'!',
'a',
'd',
'a',
'0',

' ',
'!',
y',
'y
'a
a',
'r
r',
'1
1',

Mo
onday, February 06, 20
012";

'S', 't
t', 'u', 'd
d',
'\n', ' ', '>', '>',
' ', 'i
i', 's', ':',
'y', ',
,', ' ', 'F
F',
'a', 'y
y', ' ', '0
0',
'2', '\
\0' /*very important*/
/

\n Original string (le


ength: " <<
< get_str_l
length(str)
cout << "\
<< ")
):\n ---------------------------------- \n
n " << str << "\n";
convert_to
o_upper(str);
cout << "\
\n To Upper Case:\n ---------------\n " <<
< str << "\n";

Eng. M.Hooumam Waz


zzeh | 09880047201 | Monnday, February 06, 2012
houmam.wazzeh
[email protected]
com

convert_to
o_lower(str);
cout << "\
\n To Lower Case:\n ---------------\n " <<
< str << "\n\n ";
system("pa
ause");
return 0;
}
ength(char str[])
int get_str_le
{
int len = -1;
[++len] != '\0');
while(str[
return len
n;
}
d convert_t
to_upper(char str[])
void
{
int len = get_str_length(str);
for(int i = 0; i < len; i++)
r[i] >= 'a' && str[i] <= 'z')
if(str
st
tr[i] = 'A' + str[i] - 'a';
}
d convert_t
to_lower(char str[])
void
{
int len = get_str_length(str);
for(int i = 0; i < len; i++)
r[i] >= 'A' && str[i] <= 'Z')
if(str
st
tr[i] = 'a' + str[i] - 'A';
}

string

#inc
clude <iost
tream>
#inc
clude <stri
ing>
usin
ng namespac
ce std;
d print_str
ring_array(string s);
void

Eng. M.Hooumam Waz


zzeh | 09880047201 | Monnday, February 06, 2012
houmam.wazzeh
[email protected]
com

int main()
{
r = "Hello Students!!\
\n >> Today
y is: Mond
day, February 06, 2012
2";
string str
cout << "\
\n Original string:\n-------------------------- \n "
<< st
tr << "\n\n";
print_stri
ing_array(str);
cout << " --------------------------\n\n"
";
r1, str2, str3;
string str
cout << " Enter 1st string: "; cin >> str
r1;
r2;
cout << " Enter 2nd string: "; cin >> str
r1 + ' ' + str2; // co
oncatinatio
on
str3 = str
cout << " str1 + str2: " << str
r3 << "\n";
;

:
cin

.cin

ause");
system("pa
return 0;
}
d print_str
ring_array(string s)
void
{
cout << " String Characters **{
{\n";
for(int i = 0; i < s.length(); i++)
{
< " '";
cout <<
if(s[i
i] == '\n') cout <<"\\
\n";
else cout
c
<< s[i];
cout <<
< "'";
if((i+
+1)% 10 == 0)cout << "\n";
}
th() % 10 != 0) cout <<
< "\n";
if(s.lengt
cout << " }**\n";
}

zzeh | 09880047201 | Monnday, February 06, 2012


Eng. M.Hooumam Waz
houmam.wazzeh
[email protected]
com

You might also like