Input a name and print middle name.
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], nm1[80];
int i, ln, a, b, c = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a name....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( i = 0; nm[i] != ' '; i++ );
a = i;
for ( i = ln - 1; nm[i] != ' '; i-- );
b = i;
for ( i = a + 1; i < b; i++ )
{
nm1[c++] = nm[i];
}
nm1[c] = '\0';
printf("\n\n\n\t\t MIDDLE NAME....: %s", nm1);
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], nm1[80];
int i, ln, a, b, c = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a name....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( i = 0; nm[i] != ' '; i++ );
a = i;
for ( i = ln - 1; nm[i] != ' '; i-- );
b = i;
for ( i = a + 1; i < b; i++ )
{
nm1[c++] = nm[i];
}
nm1[c] = '\0';
printf("\n\n\n\t\t MIDDLE NAME....: %s", nm1);
getch ( );
}
Click here to contact us
No comments:
Post a Comment