#include <iostream>
int main(){
std::string firstname; //variable created as a string
std::cout << "What's your first name
";
std::cin >> firstname;//asking for the users' first name
std:: cout << "Hello " << firstname
}
//Works for anyone, don't need any packages, just type this is in and run it.
// i/o example
#include <iostream>
using namespace std;
int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
return 0;
}
int x;
cout << "hurry, give me a number!: "; // Type a number and press enter
cin >> x; // Get user input from the keyboard
cout << "you picked: " << x << " !" // Display the input value
OR use:
getline >> (cin, variable-name);
instead of
cin >> x;
/*Q: Write a program that ask the user to enter the roll
number, section, CGPA and print the formatted output
on the screen?*/
#include<iostream>
using namespace std;
int main()
{
int a;
char b;
float c;
cout<<"Roll Number:"<<a;
cin>>a;
cout<<"Section :"<<b;
cin>>b;
cout<<"CGPA :"<<c;
cin>>c;
return 0;
}
int main(){
std::string firstname; //variable created as a string
std::cout << "What's your first name
";
std::cin >> firstname;//asking for the users' first name
std:: cout << "Hello " << firstname
#include <iostream>
using namespace std;
int main() {
int n1, n2;
float f1;
char c1;
cout<<"Enter two integers, a float and a char: ";
cin>>n1>>n2>>f1>>c1; //multiple input in single line
cout<<"Check: "<<n1<<n2<<f1<<c1<<endl;
return 0;
}
int x;
cout << "Type a number: "; // Type a number and press enter
cin >> x; // Get user input from the keyboard
cout << "Your number is: " << x; // Display the input value
int x;
cin >> x;
string s;
cin >> s;
cin >> variable;
// sample 1
int x;
cout << "x: ";
cin >> x;
cout << x << endl;
//sample 2
int num;
for (int i = 0; i < 10; i++){
cout << "Give a number: ";
cin >> num;
}
Code Example |
---|
Cpp :: c++ vector size |
Cpp :: append string cpp |
Cpp :: pop_back |
Cpp :: size of stack in c++ |
Cpp :: string.begin() c++ |
Cpp :: c++ get string between two characters |
Cpp :: c++ vector declaration |
Cpp :: how to delete a file in cpp |
Cpp :: deque c++ |
Cpp :: convert unsigned long to string c++ |
Cpp :: how to code string to int converter c++ |
Cpp :: could not find the task c c++ active file |
Cpp :: c++ encapsulation |
Cpp :: C++ break with for loop |
Cpp :: push local branch to another remote branch |
Cpp :: hello world in c/++ |
Cpp :: 3d vector c++ resize |
Cpp :: how to write hello world in c++ |
Cpp :: c++ int length |
Cpp :: c++ string find example |
Cpp :: C++, for-loop over an array array |
Cpp :: c++ base constructor |
Cpp :: dynamic memory c++ |
Cpp :: inserting element in vector in C++ |
Cpp :: size() in c++ SET |
Cpp :: c for loop decrement |
Cpp :: c++ changing string to double |
Cpp :: vector size |
Cpp :: substring in c++ |
Cpp :: Translation codeforces in c++ |