Answers for "user input methods c++"

C++
19

user input c++

#include <iostream>
int main(){
  std::string firstname; //variable created as a string
  std::cout << "What's your first name\n";
  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.
Posted by: Guest on June-04-2020
1

c++ program to take input from user

/*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\t :"<<b;
	cin>>b;
	cout<<"CGPA\t :"<<c;
	cin>>c;
return 0;
}
Posted by: Guest on March-17-2022

Browse Popular Code Answers by Language