C++-এ cin (ইনপুট) এবং cout (আউটপুট) অবজেক্ট ব্যবহার করা হয়। cin কীবোর্ড থেকে ইনপুট নেয়, cout স্ক্রিনে আউটপুট দেয়।
একটি সংখ্যা ইনপুট নিয়ে প্রিন্ট করা
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter the number: ";
cin >> num;
cout << "The number entered by user is " << num;
return 0;
}
আউটপুট
Enter the number: 5 The number entered by user is 5
অ্যারে ব্যবহার করে একাধিক সংখ্যা ইনপুট/আউটপুট
#include <iostream>
using namespace std;
int main() {
int a[5], i;
cout << "Enter the numbers in array: ";
for(i = 0; i < 5; i++)
cin >> a[i];
cout << "The numbers entered by user in array are: ";
for(i = 0; i < 5; i++)
cout << a[i] << " ";
return 0;
}
আউটপুট
Enter the numbers in array: 5 1 6 8 2 The numbers entered by user in array are: 5 1 6 8 2
for লুপ ব্যবহার করে অ্যারের প্রতিটি এলিমেন্ট ইনপুট এবং আউটপুট করা হয়।