belongs to collection: C scanf() Programs
Program 1: without skipping spaces between characters
#include <stdio.h> int main(void) { char x; char y; char z; //input printf("Enter 3 character values: "); scanf ("%c%c%c", &x, &y, &z); //print printf("x= \'%c\' \n", x); printf("y= \'%c\' \n", y); printf("z= \'%c\' \n", z); return 0; }
Output
Enter 3 character values: a b c x= 'a' y= ' ' z= 'b'
Here, x contains 'a', y contains ' ' (space) and z contains 'b'.
Program 2: By skipping spaces or any character between characters
#include <stdio.h> int main(void) { char x; char y; char z; //input printf("Enter 3 character values: "); scanf ("%c%*c%c%*c%c", &x, &y, &z); //print printf("x= \'%c\' \n", x); printf("y= \'%c\' \n", y); printf("z= \'%c\' \n", z); return 0; }
Enter 3 character values: a b c x= 'a' y= 'b' z= 'c'
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Program 1: without skipping spaces between characters
Output
Here, x contains 'a', y contains ' ' (space) and z contains 'b'.
Program 2: By skipping spaces or any character between characters
Output