The code for the question :
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
char name[35];
char rname[35];
int testNumber,count=0,i,j=0,checkCount=0;
scanf("%d",&testNumber);
fflush(stdin);
for(;testNumber>0;testNumber--){
gets(name);
for(i=0;name[i]!='\0';i++){
if(name[i]==' ')
count++;
}if(count!=0){
for(i=0;i<strlen(name)+1;i++){
if(i==0&&count!=0){
rname[j]=toupper(name[i]);j++;
rname[j]='.';j++;
rname[j]=' ';j++;
}
if(i!=0&&name[i-1]==' '&&checkCount!=count){
checkCount++;
if(checkCount!=count){
rname[j]=toupper(name[i]);j++;
rname[j]='.';j++;
rname[j]=' ';j++;
}
}
if(checkCount==count){
if(name[i-1]==' '){
rname[j]=toupper(name[i]);j++;
}
else{rname[j]=tolower(name[i]);
j++;}
}
}
}
else{
for(i=0;i<strlen(name)+1;i++){
if(i==0){
rname[j]=toupper(name[i]);
j++;
}
else{
rname[j]=tolower(name[i]);
j++;
}
}
}
puts(rname);
j=0;
count=0;
checkCount=0;
}
}
Can you point out where am I wrong?