+ 1
Char repeat in c
Input = hello Output = hhheeellllllooo Can someone explain me the logic as to how to implement it.
3 Respuestas
+ 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
+ 1
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 What if a number is not given (in this case 3)?
What if the repeat rate is to be initialized at runtime?
+ 1
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 Means using nested for loop right