Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Samenvatting

Summary C++ BASIC INPUT-OUTPUT

Beoordeling
-
Verkocht
-
Pagina's
5
Geüpload op
25-07-2024
Geschreven in
2023/2024

The document provides an overview of basic input-output in C++, essential for interactive programming. It covers standard input (cin) and output (cout) streams, along with common operations like reading from the keyboard and displaying text on the screen. Detailed explanations of formatted and unformatted I/O are included, with practical examples demonstrating their usage. The notes also discuss error handling and stream manipulation, highlighting best practices to ensure efficient and user-friendly input-output operations in C++.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

ELITE TUTORING




C++ Basic Input/Output
In this topic, we will learn to use the cin object to take input from the user, and
the cout object to display output to the user with the help of examples.

C++ Output
In C++, cout sends formatted output to standard output devices, such as the
screen. We use the cout object along with the << operator for displaying output.




Example 1: String Output
#include <iostream>
using namespace std;

int main() {
// prints the string enclosed in double quotes
cout << "This is C++ Programming";
return 0;
}

Output

This is C++ Programming


How does this program work?
• We first include the iostream header file that allows us to display output.
• The cout object is defined inside the std namespace. To use
the std namespace, we used the using namespace std; statement.
• Every C++ program starts with the main() function. The code execution
begins from the start of the main() function.

, ELITE TUTORING



• cout is an object that prints the string inside quotation marks " ". It is
followed by the << operator.
• return 0; is the "exit status" of the main() function. The program ends with
this statement, however, this statement is not mandatory.
Note: If we don't include the using namespace std; statement, we need to
use std::cout instead of cout .

This is the preferred method as using the std namespace can create potential
problems.
However, we have used the std namespace in order to make the codes more
readable.
#include <iostream>

int main() {
// prints the string enclosed in double quotes
std::cout << "This is C++ Programming";
return 0;
}




Example 2: Numbers and Characters Output

To print the numbers and character variables, we use the same cout object but
without using quotation marks.
#include <iostream>
using namespace std;

int main() {
int num1 = 70;
double num2 = 256.783;
char ch = 'A';

cout << num1 << endl; // print integer

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
25 juli 2024
Aantal pagina's
5
Geschreven in
2023/2024
Type
SAMENVATTING

Onderwerpen

€5,34
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
peterkuria3

Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
peterkuria3 Harvard University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
1 jaar
Aantal volgers
1
Documenten
69
Laatst verkocht
-
ELITE TUTORING

Elite Tutoring is your ultimate destination for academic success. I offer a curated selection of high-quality study tools designed to enhance your learning experience and boost exam performance. From comprehensive study guides and interactive practice exams to expert-recommended resources, I provide everything you need to excel. Trust Elite Tutoring to turn your academic challenges into triumphs and help you pass your exams with confidence.

Lees meer Lees minder
0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen