WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: CONVERT NAMES TO NUMBERS.

Search This Blog

Wednesday, 27 November 2013

CONVERT NAMES TO NUMBERS.

  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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#include<iostream.h>
#include<conio.h>
#include<string.h>
char a[27]="0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int len=0,size,i,j=0;
int num[10];
int flag=0;

class string
{
public:

struct strings
{
char name[10];


}std[10];


void read()
{

cout<<"ENTER NAME\n";

cin>>std[0].name;

len=strlen(std[0].name);

}

void calculate()
{
for(i=1;i<=27;i++)
{
if(a[i]==std[0].name[j])
{
num[j]=i;
}
}
}

void loop()
{

if(j<=len)
{
j++;


calculate();
loop();
}

}

void display()
{

for(i=0;i<len;i++)
{
cout<<num[i]<<",";
}
}
};

void main()
{
len=0;
size=0;
i=0;
j=0;
char ch;
string s;
if(flag==0)
{
clrscr();
flag=1;
}

s.read();
s.calculate();
s.loop();
s.display();

cout<<"\n\nDO U CALULATE NEXT NAME Y/N \n";
cin>>ch;

if(ch=='y' || ch=='Y')
{
main();
}
else
{
getch();

cout<<"\npress N to EXIT else press Y to continue";
cin>>ch;
if(ch=='Y' || ch=='y')
{
main();
}
}
getch();
}

No comments:

Post a Comment