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