CPP Lecture 04
CPP Lecture 04
(Using C++)
Huma Israr
Department Of Information Engineering Technology
National Skills University, Islamabad.
[email protected]
Fall 2023, BS-CS
2
Week 03
Lecture – 01
Lecture – 02
Building Programs: Basic input/output
Semester Calendar
3
Class Schedule
int age;
cin >> age;
The first statement declares a variable of type int called age,
the second statement extracts from cin a value to be stored in it.
This operation makes the program wait for input from cin;
generally, this means that the program will wait for the user to enter
some sequence with the keyboard
Program to accept values at Run Time ( Using cin>> )
//cin>> 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; }
Cin>>
cin >> a;
cin >> b;
Extractions on cin can also be chained to request more than
one datum in a single statement:
cin >> a >> b;
Using Static variables Values at runtime (using cin>>)