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