Question

1. Write a program to: Prompt the user to input an integer, a double, a character,...

1. Write a program to:

  • Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space.
  • Add a statement to also output in reverse.
  • Add a statement to cast the double to an integer, and output that integer.

2.

2. Choose the statement(s) that generate(s) this output: I wish
you were here

a.
printf("I wish", "you were here");
b.
printf("I wish\n");
printf("you were here");
c.
printf("I wish");
printf("you were here\n");
d.
printf("I wish", \n, "you were here");

Homework Answers

Answer #1

#include <stdio.h>

int main(void) {
    int userInt;
    double userDouble;
    char userChar;
    char userString[1000];

    printf("Enter integer:\n");
    scanf("%d", &userInt);

    printf("Enter double:\n");
    scanf("%lf", &userDouble);

    printf("Enter character:\n");
    scanf(" %c", &userChar);

    printf("Enter string:\n");
    scanf("%s", userString);

    printf("%d %.2lf %c %s\n", userInt, userDouble, userChar, userString);
    printf("%s %c %.2lf %d\n", userString, userChar, userDouble, userInt);

    printf("%.2lf cast to an integer is %d\n", userDouble, (int) userDouble);
    return 0;
}

b.
printf("I wish\n");
printf("you were here");
Know the answer?
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
Similar Questions
Write answer in C programming language please 2.36 LAB: Warm up: Variables, input, and casting (1)...
Write answer in C programming language please 2.36 LAB: Warm up: Variables, input, and casting (1) Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. (2 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't...
Write a program that accepts an input string from the user and converts it into an...
Write a program that accepts an input string from the user and converts it into an array of words using an array of pointers. Each pointer in the array should point to the location of the first letter of each word. Implement this conversion in a function str_to_word which returns an integer reflecting the number of words in the original string. To help isolate each word in the sentence, convert the spaces to NULL characters. You can assume the input...
This is C. Please write it C. 1) Prompt the user to enter a string of...
This is C. Please write it C. 1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be...
Write a program that reads an integer, a list of words, and a character. The integer...
Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character. Assume that the list of words will always contain fewer than 20 words. Ex: If the input is: 4 hello zoo sleep drizzle z then...
Write a Java program that prompts the user to input a word (String). The program must...
Write a Java program that prompts the user to input a word (String). The program must print the reversed word with all consecutive duplicate characters removed. The program must contain the following classes: - The StackX class (you can use the Java Stack class). - The Reverse class which must contain a private data field called “word” of type string, a constructor, and a void method called revNoDup(). The revNoDup() method must reverse the word and remove the consecutive duplicate...
In JAVA: Write a program that reads an integer, a list of words, and a character....
In JAVA: Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character. Assume that the list of words will always contain fewer than 20 words. Ex: If the input is: 4 hello zoo sleep drizzle...
Write a program in C++ coding that asks the user to input an integer between 25...
Write a program in C++ coding that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2...
Write a program that asks the user to input an integer between 25 and 50, inclusive....
Write a program that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2 relational expressions. You...
Prompt the user to enter a string of their choosing. Store the text in a string....
Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (2 pt) Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! You entered: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and,...
problem 1 Write a program that asks the user for an integer and then prints out...
problem 1 Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop. in c plus plus
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • To the TwoDArray, add a method called transpose() that generates the transpose of a 2D array...
    asked 2 minutes ago
  • How could your result from GC (retention time, percent area, etc.) be affected by these following...
    asked 12 minutes ago
  • QUESTION 17 What are the tasks in Logical Network Design phase? (Select five. ) Design a...
    asked 14 minutes ago
  • What is the temperature of N2 gas if the average speed (actually the root-mean-square speed) of...
    asked 23 minutes ago
  • Question One: Basic security concepts and terminology                         (2 marks) Computer security is the protection of...
    asked 36 minutes ago
  • In program P83.cpp, make the above changes, save the program as ex83.cpp, compile and run the...
    asked 44 minutes ago
  • the determination of aspirin in commercial preparations experment explain why the FeCl3-KCl-HCl solution was ased as...
    asked 56 minutes ago
  • Describe important events and influences in the life of Wolfgang Amadeus Mozart. What styles, genres, and...
    asked 59 minutes ago
  • 3.12 Grade Statistics Write a python module "school.py" that prints school information (first 3 lines of...
    asked 1 hour ago
  • Using python, please explain. The factorial of an integer N is the product of the integers...
    asked 1 hour ago
  • alamoto Co. manufactures a single product that goes through two processes — mixing and cooking. The...
    asked 1 hour ago
  • QUESTION 21 _______ is the ease of use with which network users can access the network...
    asked 1 hour ago