name printing.

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
#include<conio.h>
#include<stdio.h>
main()
{
char a[25];
int mi,endC,bend,i=0,j=0;
clrscr();
printf("enter the NAME\n");
scanf("%[ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMONPQRSTUVWXYZ]",a);
printf("\nFORM 1: \n");
for(;i<=24;i++)
{
if(a[i]==' ')
{
j++;
}
if((j==0&&a[i]!=' ')||(j==3&&a[i]!=' '))
{
printf("%c",a[i]);
}
if(j==1)
{
printf(" %c. ",a[i+1]);
j++;
}
if(a[i]=='\0')
break;
}
printf("\nFORM 2: \n");
printf("%c.",a[0]);
i=j=0;
for(;i<=24;i++)
{
if(a[i]==' ')
{
j++;

 if(j==1)
  {
  printf("%c.",a[i+1]	);
  }}
if(a[i]=='\0')
{break;}
if(j==2)
  {
  printf("%c",a[i]);
  }
}
printf("\nFORM 3: \n");
for(i=0,j=0;i<=24;i++)
{
if(a[i]==' ')
{
j++;
}
if(j==1)
{
mi=a[i+1];
j++;
}
if(j==3)
{
printf("%c",a[i+1]);
}
if(a[i]=='\0')
break;
}
printf(" %c.%c.",a[0],mi);
getch();
}

output should be

mayank kumar jha
FORM 1:
firstname middleinitial. last name 
FORM 2:
firstinitial.secondinitial. lastname
FORM 3:
lastname firstinitial.secondinitial.



is there a shorter and easier way to do this....... way in which one can plz reply.....
this is a C++ forum bro, head over to a C forum for help ;)
Topic archived. No new replies allowed.