+ 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 Answers
+ 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