-2
The program does not print the first letter of each name.
nome[i]=nome[i+1];
I need to make a program that enters the name of the person, tells how many letters A
has the name of that person and says the first letter of their names, for example: Joao Vinicios, the program will show me J.V.
This is what I’ve done so far:
#include <stdio.h>
#include <conio.h>
int main()
{
char nome[99];
int soma,i;
printf("Digite o nome completo:\n");
gets(nome);
soma=0;
for(i=0;nome[i] != 0; i++) //For para mostrar quantos a tem o nome da pessoa
{
if(nome[i]=='a')
{
soma=soma+1;
}
}
for(i=0; nome[i]!=0; i++) // For para pegar a primeira letra de cada nome da pessoa
{
if(nome[i] == ' ')
{
soma=so
nome[i]=nome[i+1];
printf("%s\n",nome[i]);
}
}
printf("Seu nome tem %d letras 'A'" ,soma); // imprimi na tela quantos A tem o nome da pessoa
getch();
return 0;
}
You need to report what your specific problem is.
– Fagner Fonseca
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero