How do I write a program in C to accept a name and display it during the execution of the programme?
Okay, first of all we will allocate the memory for storing the name we will store it in ‘name’ array which is of char type.#include int main(){ char name[20]; //I hope the user is not Russian :-P //I've allocated 20 bits you can allocate as much as you want printf("Enter your name: ");//We will use fgets to store the input as gets is a dangerous function and can overload memory buffers fgets(name,20,stdin); printf("%s",name); //display the name return 0;}So this is how you can input and display the name during runtime.Happy Coding!
Write a complete program whose class name is Hello and that displays Hello, world on the screen.?
class HelloWorld { public static void main(String args[]) { System.out.println("Hello, World!"); } }
Please help. A C++ program that displays your name and address.?
Good day everyone, I am a total newbie to C++, so please bear with me if I have a lot of mistakes. I wrote a program as follow: #include int main() { using namespace std; cout << "Please Enter Your Name: "; char name[20]; cin >> name; cout << "Enter your Address: "; char address[40]; cin >> address; cout << "Your name is: " << name << " And your address is: " << address; cin.get(); cin.get(); return 0; } It works fine, but once I enter: Europe, Belgium, XYZ as an address, it does not show the last output. But if I enter: Belgium as address, it shows the last cout statement. My guess is it doesn't accept SPACE for the character data type. how can I fix this problem. Kindly guide me. Thank you. S.