Write a program to read the name ANIL KUMAR GUPTA in three parts using the scanf statement
and to display the same in the following format using the printf statement.
(a) ANIL K. GUPTA
(b) A.K. GUPTA
(c) GUPTA A.K.
#include <stdio.h>
void main()
{
char n[4],mn[5],ln[5];
clrscr();
printf("Enter the name middle name and last name:");
scanf("%s %s %s",n,mn,ln);
printf("%s %.1s. %s\n",n,mn,ln);
printf("%.1s.%.1s.%s\n",n,mn,ln);
printf("%s %.1s.%.1s.",ln,n,mn);
getch();
}
and to display the same in the following format using the printf statement.
(a) ANIL K. GUPTA
(b) A.K. GUPTA
(c) GUPTA A.K.
#include <stdio.h>
void main()
{
char n[4],mn[5],ln[5];
clrscr();
printf("Enter the name middle name and last name:");
scanf("%s %s %s",n,mn,ln);
printf("%s %.1s. %s\n",n,mn,ln);
printf("%.1s.%.1s.%s\n",n,mn,ln);
printf("%s %.1s.%.1s.",ln,n,mn);
getch();
}
No comments:
Post a Comment