Write a program email c that asks the user for a first and l

Write a program email. c that asks the user for a first and last name, and prints out the user\'s UCSD email ID consisting of the first letter of the first name followed by at most 7 letters of the last name. The first name is assumed to consist of a single word and everything after the first space are assumed to be part of the last name. When creating the email ID, convert all letters to lower case, and ignore any hyphens and any spaces in the last name. You can assume that the user will always enter at least two words. (~)$ a. out Name: Hillary Clinton UCSD email ID: hclinton@ucsd.edu (~) $ a. out Name: Elizabeth Bowes-Lyon UCSD email ID: ebowesly@ucsd.edu (~) $ a. out Name: Andrew lloyd webber UCSD email ID: alloydwe@ucsd.edu (~) $ a. out Name: Jean-Claude Van Damme UCSD email ID: jvandamm@ucsd.edu (~)$

Solution

#include<stdio.h>

char toLowerCase(char );

int main()
{
char firstName[100], lastName[100],email[30];
scanf(\"%s\",firstName);
scanf(\"%s\",lastName);
int index = 0,i = 0;
email[index++] = toLowerCase(firstName[0]);
while(index < 8)
{
if(lastName[i] == \'\\0\')
break;
if(lastName[i] != \' \' || lastName[i] != \'-\')
email[index++] = toLowerCase(lastName[i]);
i++;
}
printf(\"%s\ \", email );
}

char toLowerCase(char c)
{
char output;
int temp = c;
printf(\"%d\ \", temp);
if((int)c >= 97 && (int)c <= 122)
output = c;
else
{
output = (c%65 + 97);
}
printf(\"%c\ \", output);
return output;
}

 Write a program email. c that asks the user for a first and last name, and prints out the user\'s UCSD email ID consisting of the first letter of the first nam

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site