Question

write using C language

Part A: Using any loop statement Ask the user to enter first name and last name Read the characters the user typed using getchar) function. While reading you have to make sure you ignore the end of line statement. Print the characters on the screen using putchar () function and in this format First Name:Jack Last Name:Damon

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey,

Below is the code to your question

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    char c,first[1000],last[1000];
    int count1=0,count2=0;
    printf("Enter first name: ");
while((c = getchar()) != '\n' && c != EOF)
{
    first[count1++]=c;
}
first[count1]='\0';

printf("Enter last name: ");

while((c = getchar()) != '\n' && c != EOF)
{
    last[count2++]=c;
}
last[count2]='\0';
printf("First name:");
int i;
for(i=0;i<count1;i++)
    putchar(first[i]);
printf("\nLast name:");
for(i=0;i<count2;i++)
    putchar(last[i]);
   return 0;
}

Filtestimain.exe Enter first name: Jack Enter last name: Damon First name Jack Last name:Damon Process returned (8x8) executi

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
write using C language Part A: Using any loop statement Ask the user to enter first...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • Pythpn #Exercise 1 #Ask the user for a three letter word using the prompt: three letter...

    Pythpn #Exercise 1 #Ask the user for a three letter word using the prompt: three letter word? (include a space after the ?) #Display the entire word #Display the word vertically, one letter at a time using print statements and the string index #For example, if the user enters baa, the output should be (ignore # signs): #baa #b #a #a #Exercise 2 #Ask the user for a number using the prompt: first number? (include a space after the ?)...

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • //Done in C please! //Any help appreciated! Write two programs to write and read from file...

    //Done in C please! //Any help appreciated! Write two programs to write and read from file the age and first and last names of people. The programs should work as follows: 1. The first program reads strings containing first and last names and saves them in a text file (this should be done with the fprintf function). The program should take the name of the file as a command line argument. The loop ends when the user enters 0, the...

  • Write a C code using switch statement that will ask the user to enter a character....

    Write a C code using switch statement that will ask the user to enter a character. This character should be one of the first three characters of your name. The code then should check for the value of the character and output the following: If the character is the same as yo&r first letter then output "X=10" If the character is the same as your second letter then output "Y=5" If the character is the same as your Third letter...

  • Write an interactive program exam1 that loops Loop and asks the user at the end of...

    Write an interactive program exam1 that loops Loop and asks the user at the end of the loop to continue or not Ask the user to enter an alphanumeric US phone number Read the line of text from the screen Check if the entered string is a valid phone number using isValid(Line) if it is valid number { call toNumeric(line) to convert it to digits print Line after conversion } bool isValid(char line[]) { //st must have 10 digits and...

  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

  • Ask the user to enter a message Ask the user how many time they want to...

    Ask the user to enter a message Ask the user how many time they want to print the message Then use "while","do-while" and "for" loop to print the message. Show the number at the beginning of the lines when printing. For example: Enter your message: Welcome to Java How many time you want to print this message: 3 Using "while" loop: 1=> Welcome to Java 2=> Welcome to Java 3=> Welcome to Java Using "do-while" loop: 1=> Welcome to Java...

  • First, ask the user for a positive integer called “length”. If the user does not provide...

    First, ask the user for a positive integer called “length”. If the user does not provide an integer, or if the integer is not positive, then ask again, by asking inside a while loop. The acceptable integer is intended to indicate the user’s desired twist length. A twist is always three lines long, and made of slash characters and X characters. For example, if length is 25, then your code should print out this: Simple output: IXI XI XI XI...

  • design a program (.js extension) using JS Language The program should ask the user for their...

    design a program (.js extension) using JS Language The program should ask the user for their name. The program should than print "hello, name.. what is your age?" The program should than calculate age * 365 and print you have lived for over ... days An if statement should than be added after stating that if the user is over 21 years of age it should print, "You are an adult" if the user is under 21 years of age....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT