Question

(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

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

Code:

#include<stdio.h>               //header files including
int main()
{   char option="Y";           //by default set the option to Y so that user can enter the Full Name once
  
   while (option!='N')                   //iterating loop untill user Enter N
      
       {
           char firstname[100],lastname[100],ch;       //declaring firstname and last name varibales and ch is a variable used for temporary purpose
          
           int account_balance;               //account_balance int variable
          
           printf("\nEnter the First Name : ");       //asking user to enter the first name
          
           scanf("%s",firstname);                       //taking input from user
          
           printf("\nEnter the Last Name : ");               //asking user to enter the last name
          
           scanf("%s",lastname);
          
           printf("\nEnter the Account Balance : ");       //asking user to enter the balance
          
           scanf("%d",&account_balance);                   //taking balance from user as input
          
           printf("\nEnter Y If You Want to Enter Another Full Name Or Enter N : ");           //asking user to enter Y or N
          
           scanf("%c",&ch);                   //scanf is used to catch the \n that was entered after the printf statement
          
           scanf("%c",&option);       //asking user to enter the option Either Y or N
       }
   return 0;}

Code and Outputs Screenshots:

Note : if you have any queries please post a comment thanks a lot...always available to help you...

Add a comment
Know the answer?
Add Answer to:
(2) Write a loop wherein you ask the user if they want to enter another complete...
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 using C language Part A: Using any loop statement Ask the user to enter first...

    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

  • Write a C++ program that produces the following output: /* OUTPUT Enter your age: 21 Enter...

    Write a C++ program that produces the following output: /* OUTPUT Enter your age: 21 Enter the last name: Lee Hello Tom Lee. You are 21 years old. Press any key */   Declare an array named: firstName The array is a c_string, i.e., it is a null-terminated character array. The size of the array is 10. Assign a first name to it when it is declared.   Declare an array named: lastName The array is a c_string, The size of 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...

  • Write Java code that does the following Ask the user to enter a file name. Ask...

    Write Java code that does the following Ask the user to enter a file name. Ask the user for two integers as the lower bound and the upper bound. Use a loop to write all the odd numbers between the lower bound and the upper bound (inclusive) to the file, and then close the file. Use either while loop, do while loop, or for loop to complete the program. PrintWriter class is used. The file is closed before the program...

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

  • Problem 1 Write a Python program to do the following: (A) Ask the user to enter...

    Problem 1 Write a Python program to do the following: (A) Ask the user to enter as many integers from 1 to 10 as he/she wants. Store the integers entered by the user in a list. Every time after the user has entered an integer, use a yes/no type question to ask whether he/she wants to enter another one. (B) Display the list. (C) Calculate and display the average of the integers in the list. (D) If the average is...

  • Write a Python program, with comments, to do the following:                        Ask the user to enter...

    Write a Python program, with comments, to do the following:                        Ask the user to enter a string with at least 7 characters. Assume user will enter a valid string. Assign the string to a variable str1 and print str1. In a loop do the following: Update the value of str1 so that the first character from the current value of str1 is removed and added to the end. Print the updated str1.       The loop should continue until updated...

  • This program will ask the user to enter a number of players, then ask the user...

    This program will ask the user to enter a number of players, then ask the user for each player's name and score. Once all of the players have been entered, the program will display a bar chart with each of their scores scaled as a percentage of the maximum score entered. See below for details on exactly how this should work - an example transcript of how the program should work is shown below (remember that values entered by the...

  • •create a new savings account object (for choice 2). •ask the user to enter an initial...

    •create a new savings account object (for choice 2). •ask the user to enter an initial balance which should be greater than 50. If the entered amount is less than 50, the program will ask the user to enter another amount. This continues until an amount greater than 50 is entered. •Set the balance of the savings account object by calling the setBalance() method. •Ask the user to deposit an amount. Deposit that amount and display the balance of the...

  • Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a...

    Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...

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