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...

  • 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...

  • 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...

  • (2) Write a loop wherein you ask the user if they want to enter another complete...

    (2) Write a loop wherein you ask the user if they want to enter another complete name (lastname , firstname) and account balance. Have the user respond with a single character 'y' or 'n' (note: the user will have to hit the key after the single character ‘y’ or ‘n’) c is the language used

  • (java) Write a While loop that prompts the user for only even numbers. Keep prompting the...

    (java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...

  • Programming in C: Using a nested for loop create the pattern below. Prompt the user for...

    Programming in C: Using a nested for loop create the pattern below. Prompt the user for the height (number of rows) and width (number of characters per line) for pattern A. You may use any number for height and width, just as long as the basic pattern is preserved. Call a function to print the pattern. This function receives the height and width as inputs (parameters) but does not return a value. Make use of an if structure to instruct...

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
ADVERTISEMENT