> For the complete documentation index, see [llms.txt](https://mun.gitbook.io/c/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mun.gitbook.io/c/solution/8-character-and-string/7.2-character-input.md).

# 7.2 Character Input

## 7.2 Character Input

1. \[0.5] Take a Character input from the user and print the Character. *(Repeated)*
2. \[0.6] Take two Character inputs separated by space/newline from the user and print both Characters. *(Repeated)*
3. \[1] Take Character input and print the character for N times (Take Input N from the user at the beginning)
4. \[2] Take Character input until the input is "0".

## সমাধান

### \[0.5] Take a Character input from the user and print the Character. *(Repeated)*

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch;
    
    scanf("%c", &ch);
    printf("%c\n", ch);
    
    return 0;
}
```

{% endcode %}

### \[0.6] Take two Character inputs separated by space/newline from the user and print both Characters. *(Repeated)*

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch1, ch2;
    
    scanf(" %c %c", &ch1, &ch2);
    printf("%c %c\n", ch1, ch2);
    
    return 0;
}
```

{% endcode %}

### \[1] Take Character input and print the character for N times (Take Input N from the user at the beginning)

{% code lineNumbers="true" %}

```c
#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;
}
```

{% endcode %}

### \[2] Take Character input until the input is "0".

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch;
    
    while(scanf(" %c", &ch) && ch != '0') {
        printf("%c\n", ch);
    }
    
    return 0;
}
```

{% endcode %}
