printf(), cout <<"".,,, what the difference? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

printf(), cout <<"".,,, what the difference?

printf() and cout <<"" what the difference? this tow in c++

3rd Jul 2018, 9:45 PM
I -_- D
I -_- D - avatar
9 Answers
+ 6
Both cout and printf are used for outflow of data i.e. output. cout is a output stream while printf is a function. cout requires header file iostream while printf requires header file stdio.h cout is used only by c++ while printf can be used by both c and c++.
4th Jul 2018, 2:10 PM
Hrishikesh Kaulwar
+ 6
printf is used for printing out formatted strings or integers taken in as arguments its similar string concatenation but the plus sign is not needed. cout used to print out strings or integers to console.
3rd Jul 2018, 10:18 PM
D_Stark
D_Stark - avatar
+ 2
also, if you need to use cout you should include iostream library, and if you need to use printf you should include cstdio library
4th Jul 2018, 12:27 PM
Vladyslav Kovalenko
Vladyslav Kovalenko - avatar
+ 1
no difference, both used for the same purpose.
29th Jul 2018, 6:46 AM
Ali Hassan
Ali Hassan - avatar
+ 1
Ali Hassan So why do they both exist?
29th Jul 2018, 7:56 AM
I -_- D
I -_- D - avatar
+ 1
cout usually used in c++ interface, printf usually used in c,c# or MATLAB. but there purpose is to show output.
29th Jul 2018, 8:04 AM
Ali Hassan
Ali Hassan - avatar
+ 1
generally both are used for same purpose ,i.e to print something.the only difference is that both are defined in two separate header file,studio.h for printf(),and iostream.h for cout<<"";..
7th Oct 2018, 8:10 AM
Radha Gupta
Radha Gupta - avatar
0
printf occurs in c where course occurs in c++
6th Jul 2018, 4:04 AM
Lakkepogu Sujaro
Lakkepogu Sujaro - avatar
- 3
Its easy right
4th Jul 2018, 10:31 PM
Gwen Moncrief