-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14_char_array.cpp
54 lines (54 loc) · 970 Bytes
/
14_char_array.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// array of characters
/*
#include<iostream>
using namespace std;
int main ()
{
char name[20];
cout<<"enter the name "<<endl;
cin.getline(name ,20); //cin.getline used in this
cout<<name;
return 0 ;
}
*/
// directly using string
/*
#include<iostream>
#include<cstring>
using namespace std;
int main ()
{
string name;
cout<<"enter name "<<endl;
getline(cin,name);
cout<<name;
return 0;
}
*/
// wap to find a word is pailendrome or not
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
int n,count =0;
cout<<"enter the length of word\n";
cin>>n;
char a[n+1];
cout<<"enter the word\n";
cin>>a;
for(int i=0;i<n;i++)
{
if (a[i]==a[n-1-i])
{
count++;
}
}
if(count==n)
{
cout<<"pailendrome\n";
}
else
{
cout<<"not pailendrome";
}
return 0 ;
}