The program gets the string S and a character C as input. The characters in the input string are displayed until the specified input character in the string.
For example,
Input
Evaluate
l
Output
Eva
Program
#include<stdio.h>
#include <stdlib.h>
int main()
{
char S[100],C;
int i=0;
scanf("%s %c",S,&C); //Leave a space between %s and %c to skip enter key input
while(S[i]!=C)
{
printf("%c",S[i]);
++i;
}
}
For example,
Input
Evaluate
l
Output
Eva
Program
#include<stdio.h>
#include <stdlib.h>
int main()
{
char S[100],C;
int i=0;
scanf("%s %c",S,&C); //Leave a space between %s and %c to skip enter key input
while(S[i]!=C)
{
printf("%c",S[i]);
++i;
}
}
No comments:
Post a Comment