Matching Last Character (C++ Sample Program)
// Coding With Farhan - A program to matches the last character of the name with the alphabet you want. I am using n.
#include<iostream> // standard header file for input and output
#include<cstring> // header file for using c-type string functions
using namespace std;
int main() // starting of the program
{
char full_name[50]; // taking an array of characters of size 50
cout << "Enter Your Full Name :- "; // show to the user what they have to give as a input
cin.getline(full_name,50); // for taking input from the user
int number_of_characters=strlen(full_name);
// delcaring a variable and iniatializing it with the total length of the full name .... strlen function is used to calculate the whole length of the word
if(full_name[number_of_characters- 1] == 'n') // using if statement to match the last character of the full name to n, you can use any alphabet you want
// number_of_character-1 means that the array of full_name is starting from 0 but the strlen function srtarts calculating from 1 so by this number_of_characters will match with the array of full_name
{
cout << "The Last Character Of The Name Ends With n";.
}
else // if does not matches then this part will run
{
cout << "The Last Character Of The Name Does Not Ends With n";
}
}
// Thank You, I Hope That You Will Like That Program!!!!!
Comments
Post a Comment