Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

what does this mean? scanf("%d",&n);

OpenStudy (anonymous):

This means that the program will wait for input and take a (d)ecimal and place it in the address of the n variable .

OpenStudy (anonymous):

so can u rephrase it in "cin" ?? because scanf means cin right??

OpenStudy (anonymous):

It means it will prompt the user to input a integer number and store its value in 'n'. %d signifies that the data type of input should be an integer. & signifies that it is stored in a particular address.

OpenStudy (anonymous):

they are similar. scanf is for c and cin is a c++ construct.

OpenStudy (anonymous):

yep. but i want it to be just clear. ahmm by just showing "cin and cout". so can u rephrase that into cin ??

OpenStudy (anonymous):

im using c++ actually not c. so im really confuse

OpenStudy (anonymous):

#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << endl; return 0; }

OpenStudy (anonymous):

The scanf requires the type to be specified, the cin will display based on the type of variable.

OpenStudy (anonymous):

can u show me a code. printing a pyramid ? for example, i type 5. this would be the output: * ** *** **** *****

OpenStudy (anonymous):

Pyramid example: #include <iostream> using namespace std; int main() { int count; cin >> count; for(int i = 1; i <= count ; i++) { for (int j = 1; j <= i; j++) { cout << "*" ; } cout << endl; } return 0; }

OpenStudy (anonymous):

if you use c++ use cin

OpenStudy (llib_xoc):

Scanf is a C standard-library function which reads data from the stdin channel, decodes it according to the format string (argument 1), and stores it in the variable that argument two points to. Lots more info at http://dinkum.com/manuals/?manual=compleat&page=lib_scan.html#Scan%20Functions.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!