READING/PRINTING A GROUP OF CHARACTERS (METHOD 1)(fflush())
#include <stdio.h>
void main()
{
char st[30];
int n,i;
printf("How
many characters do u want to enter");
scanf("%d",&n);
printf("enter
the characters(name):");
fflush(stdin);
for(i=0;i<n;i++)
scanf("%c",&st[i]);
printf("the
entered name is :");
for(i=0;i<n;i++)
printf("%c",st[i]);
}
OUTPUT
How many characters do u want to enter 13
Enter the character(name):incredible india
The entered name is :incredible in
READING/PRINTING A GROUP OF CHARACTERS (METHOD 2)
#include <stdio.h>
void main()
{
char st[30];
printf("enter
the characters(name)");
scanf("%s",st);
printf(" the
entered name is %s",st);
}
OUTPUT
Enter the characters(name) sirisha sanapathi
The entered name is sirisha
No comments:
Post a Comment