7.2 Character Input
7.2 Character Input
- [0.5] Take a Character input from the user and print the Character. (Repeated) 
- [0.6] Take two Character inputs separated by space/newline from the user and print both Characters. (Repeated) 
- [1] Take Character input and print the character for N times (Take Input N from the user at the beginning) 
- [2] Take Character input until the input is "0". 
সমাধান
[0.5] Take a Character input from the user and print the Character. (Repeated)
#include<stdio.h>
int main(){
    char ch;
    
    scanf("%c", &ch);
    printf("%c\n", ch);
    
    return 0;
}[0.6] Take two Character inputs separated by space/newline from the user and print both Characters. (Repeated)
#include<stdio.h>
int main(){
    char ch1, ch2;
    
    scanf(" %c %c", &ch1, &ch2);
    printf("%c %c\n", ch1, ch2);
    
    return 0;
}[1] Take Character input and print the character for N times (Take Input N from the user at the beginning)
#include<stdio.h>
int main(){
    int n, i;
    char ch;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf(" %c", &ch);
        printf("%c\n", ch);
    }
    
    return 0;
}[2] Take Character input until the input is "0".
#include<stdio.h>
int main(){
    char ch;
    
    while(scanf(" %c", &ch) && ch != '0') {
        printf("%c\n", ch);
    }
    
    return 0;
}Last updated