Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

alfers101

  • 2 years ago

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

  • This Question is Closed
  1. ecdown
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 3

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

  2. alfers101
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. DBhatta
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. ecdown
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 3

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

  5. alfers101
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  6. alfers101
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  7. ecdown
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 3

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

  8. ecdown
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 3

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

  9. alfers101
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  10. ecdown
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 3

    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; }

  11. Tomas.A
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    if you use c++ use cin

  12. llib_xoc
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  13. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.