Question

In: Computer Science

Define a char variable. Read a char value from the keyboard into the variable. Print the...

Define a char variable.

Read a char value from the keyboard into the variable.

Print the variables value.

Solutions

Expert Solution

IN C:

CODE:

#include<stdio.h>
int main()
{
   char a;scanf("%c",&a);
   printf("variable is: %c", a);
   return 0;
}

OUTPUT:

IN C++:

CODE:

#include<iostream>
using namespace std;
int main()
{
   char a;cin>>a;
   cout<<"variable is: "<<a;
   return 0;
}

OUTPUT:

IN PYTHON:

IN JAVA:

CODE:

import java.util.*;
class A
{
   public static void main(String args[])
   {
       Scanner sc = new Scanner(System.in);
       char a = sc.next().charAt(0);
       System.out.println("Variable is: " + a);
   }
}

OUTPUT:


Related Solutions

Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
(C++) Write a program that reads a list of integers from the keyboard and print out...
(C++) Write a program that reads a list of integers from the keyboard and print out the smallest number entered. For example, if user enters 0 3 -2 5 8 1, it should print out -2. The reading stops when 999 is entered.
JAVA Input a phrase from the keyboard, if the phrase contains "red" or "RED" print out...
JAVA Input a phrase from the keyboard, if the phrase contains "red" or "RED" print out "red" . if the phrase contains "blue" or "BLUE" output "blue" In all other cases print "No Color" For example: If the input was "Violets are BLUE" your output should be "blue" If the input was "Singing the blues" output "blue" If the input was "I have a pure bred puppy" your output should be "red" If the input was "Today is Monday" output...
WRITTEN IN C PLEASE. Write a switch statement that tests the value of the char variable...
WRITTEN IN C PLEASE. Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y, the message Your request is being processed is printed if response is n, the message Thank you anyway for your consideration is printed if response is h, the message Sorry, no help is currently available is printed for any other value of response, the message Invalid entry; please try again is printed
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes the character x from string s. For s[] = “America”, a call to deleteSymbol(s, ‘a’) converts s[] = “Ame”
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print...
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print out "n" lines as follows: 0 0 1 0 1 2 0 1 2 3 … 0 1 2 3 … n-1
Write a C++ program to read in a list of 10 integers from the keyboard. Place...
Write a C++ program to read in a list of 10 integers from the keyboard. Place the even numbers into an array called even, the odd numbers into an array called odd, and the negative numbers into an array called negative. Keep track of the number of values read into each array. Print all three arrays after all the numbers have been read. Print only the valid elements (elements that have been assigned a value). a. Use main( ) as...
Read in the names of several grocery items from the keyboard and create a shopping list...
Read in the names of several grocery items from the keyboard and create a shopping list using the Java ArrayList abstract data type. Flow of Program: 1) Create a new empty ArrayList 2) Ask the user for 5 items to add to a shopping list and add them to the ArrayList (get from user via the keyboard). 3) Prompt the user for an item to search for in the list. Output a message to the user letting them know whether...
Write a java program to read a string from the keyboard, and count number of digits,...
Write a java program to read a string from the keyboard, and count number of digits, letters, and whitespaces on the entered string. You should name this project as Lab5B. This program asks user to enter string which contains following characters: letters or digits, or whitespaces. The length of the string should be more than 8. You should use nextLine() method to read string from keyboard. You need to extract each character, and check whether the character is a letter...
Write an LC-3 program that will repeatedly read a character from the keyboard. For each character...
Write an LC-3 program that will repeatedly read a character from the keyboard. For each character read in, your program will print a neat message that echoes the input value, and the ASCII character code of the input character in hexadecimal. It will run forever: no HALT or End of processing is required. For example: Please press a key: You pressed 'z' which is x7A Please press a key: You pressed '@' which is x40 Please press a key: You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT