2. C scanf() function: scanf() function is used to read - TopicsExpress



          

2. C scanf() function: scanf() function is used to read character, string, numeric data from keyboard Consider below example program where user enters a character. This value is assigned to the variable “ch” and then displayed. Then, user enters a string and this value is assigned to the variable ”str” and then displayed. EXAMPLE OF C SCANF FUNCTION #include int main() { char ch; char str[100]; printf("Enter any character "); scanf("%c", &ch); printf("Entered character is %c ", ch); printf("Enter any string ( upto 100 character ) "); scanf("%s", &str); printf("Entered string is %s ", str); } OUTPUT Enter any character a Entered character is a Enter any string ( upto 100 character ) hai Entered string is hai
Posted on: Sun, 29 Sep 2013 04:15:05 +0000

Trending Topics



Recently Viewed Topics




© 2015