Skip to content

Instantly share code, notes, and snippets.

@kainio
Created December 19, 2018 23:48
Show Gist options
  • Save kainio/e315f30fbd92b40fcc3f9e6494aa236c to your computer and use it in GitHub Desktop.
Save kainio/e315f30fbd92b40fcc3f9e6494aa236c to your computer and use it in GitHub Desktop.
Afficher le titre et le nom de l'ulitlisateur comme un message de bienvenu
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
//déclaration des variales de type string
char prenom[20];
char titre[10];
//saisire le prenom
printf("entrez votre prenom: ");
scanf("%s",prenom);
//saisir le titre
printf("entrez votre titre: ");
scanf("%s",titre);
//vérifier si le titre donné par l'ustilisateur correspond au titre prédéfinie (comme "Mr")
if(strcmp(titre,"Mr") == 0)
{
printf("%s %s, soyez le bienvenu", titre,prenom);
} else if ((strcmp(titre, "Ms") == 0) || (strcmp(titre, "Mme") == 0))
{
printf("%s %s, soyez la bienvenue", titre,prenom);
} else {
printf("Titre inconnu");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment