Question

In: Computer Science

Declare a string variable and initialize it with your first name ( in C++)

Declare a string variable and initialize it with your first name ( in C++)

Solutions

Expert Solution

program:


#include <iostream>

using namespace std;

int main()
{
string name; //declare string variable

name = "micheal"; //intialized to first name
  
cout<<name; // print name

return 0; //return statement
}

output:


Related Solutions

A) Declare a String variable called myString0 and initialize it to "Java". B) Declare a String...
A) Declare a String variable called myString0 and initialize it to "Java". B) Declare a String variable called myString1 and initialize it to "Programming". C) Declare a String variable called myString2 and initialize it to "Language". D) Print the concatenation of myString0 + " is a " + myString1 + " " + myString2 + ".". E) Print the sum of the lengths of myString1 and myString2 (must call the length() method). F) Print the 2nd, 4th, and 7th character...
Declare and initialize an array to store the course name or code.
Declare and initialize an array to store the course name or code.
Write a script that will first initialize a string variable that will store x and y...
Write a script that will first initialize a string variable that will store x and y coordinates of a point in the form ‘x 3.1 y 6.4’. Then, use string manipulating functions to extract the coordinates and plot them. ANS % create a string variable of the form 'x 3.1 y 6.4' % extract the x and y coordinates and plot str = 'x 2.3 y 4.5'; [letter rest] = strtok(str); [x rest] = strtok(rest); [letter rest] = strtok(rest); y...
Write a program in c# that declare a variable and store user name jjohn in. Then,...
Write a program in c# that declare a variable and store user name jjohn in. Then, write a statement that will make your program display at the screen the content of that variable, followed by " I would like to know your height in centimeter. Please enter it:". Then, write a statement that will store the value entered by the user, allowing decimal numbers ie some precision, a fraction part. Finally, write statements (more than one can be needed) so...
How does one declare a class variable in C#?
How does one declare a class variable in C#?
In Java, Here is a basic Name class. class Name { private String first; private String...
In Java, Here is a basic Name class. class Name { private String first; private String last; public Name(String first, String last) { this.first = first; this.last = last; } public boolean equals(Name other) { return this.first.equals(other.first) && this.last.equals(other.last); } } Assume we have a program (in another file) that uses this class. As part of the program, we need to write a method with the following header: public static boolean exists(Name[] names, int numNames, Name name) The goal of...
Hello, this is for C#. Initialize variable balance to 1000 dollars. Prompt the player to enter...
Hello, this is for C#. Initialize variable balance to 1000 dollars. Prompt the player to enter a wager. Check that wager is less than or equal to balance, and if it’s not, have the user reenter wager until a valid wager is entered. After a correct wager is entered, run one game of craps. If the player wins, increase balance by wager and display the new balance. If the player loses, decrease balance by wager, display the new balance, check...
Hello, this is for C#. Initialize variable balance to 1000 dollars. Prompt the player to enter...
Hello, this is for C#. Initialize variable balance to 1000 dollars. Prompt the player to enter a wager. Check that wager is less than or equal to balance, and if it’s not, have the user reenter wager until a valid wager is entered. After a correct wager is entered, run one game of craps. If the player wins, increase balance by wager and display the new balance. If the player loses, decrease balance by wager, display the new balance, check...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
Questions: 1) // declare integer variable sum equal to zero // declare variable integer i //...
Questions: 1) // declare integer variable sum equal to zero // declare variable integer i // declare while loop condition where i is less then 25 // inside of brackets calculate the sum of i (addition) // increment i // outside the loop print the sum of values ============================================= 2) Create a sentinel value example if I press number 0 it will display the sum of data // create a scanner // prompt the user to to enter the numbers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT