Q2
#include <stdio.h>
int main()
{
char str[100], str1[100];
printf("Enter Your name:- ");
gets(str);
int n, k = 0;
printf("Enter the spaces you want:- ");
scanf("%d", &n);
for (int i = 0; str[i] != '\0'; i++)
{
if (str[i] == ' ')
{
str1[k] = str[0];
k++;
}
else
{
str1[k] = str[i];
k++;
}
for (int j = 0; j < n; j++)
{
str1[k] = ' ';
k++;
}
}
str1[k] = '\0';
for (int i = 0; str1[i] != '\0'; i++)
{
printf("%c", str1[i]);
}
return 0;
}
Comments
Post a Comment