Char repeat in c | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Char repeat in c

Input = hello Output = hhheeellllllooo Can someone explain me the logic as to how to implement it.

9th May 2020, 2:37 AM
Saaquib Motiwala
3 Respostas
+ 3
#include <stdio.h> #include<string.h> int main() { char b[100]; int i, a; scanf("%d",&a); scanf("%s",b); for(i=0;i<a;i++) { printf("%c",b[i]); printf("%c",b[i]); printf("%c",b[i]); } return 0; } This is the code and it works perfectly šŠš¢š¢š›šØ š†š”ššš²ššš„ Thanks
9th May 2020, 3:36 AM
Saaquib Motiwala
+ 1
šŠš¢š¢š›šØ š†š”ššš²ššš„ What if a number is not given (in this case 3)? What if the repeat rate is to be initialized at runtime?
9th May 2020, 3:41 AM
Saaquib Motiwala
9th May 2020, 3:52 AM
Saaquib Motiwala