#include <stdio.h>
int main(void){
char var;
var = getchar();
printf(" Welcome to %c",var);
return 0;
}
Using getchar function we can interact with user and execute some conditional statements. WE will ask user if C programming is easy or difficult. Based on the input data we will display a message using one if condition checking.
#include <stdio.h>
int main(void){
char var;
printf( "Do you like C programming ? Press Y or N ");
var = getchar();
if(var == 'Y')
{
printf(" Yes C is very interesting language");
}
else
{
printf (" Why ? It is easy to learn here, need practice only");
}
return 0;
}
nurr | 10-11-2013 |
hi, how i'm going to change this code using string, for example Y change it to YES, and N change it to NO. thanks for help... |
Michael Ziile | 22-01-2019 |
illustrate with examples a)reading character and string variable b)writing character and string variable |