Solved

Easy C++ commands

Posted on 2000-02-28
3
185 Views
Last Modified: 2010-04-02
I am trying to learn C++,and I haven't bought any books or anything yet so I have a few questions.
I think I've understood that with int var = value -- you set a variabel value, but how do i set it to something a user is prompted for?
so that i ask the user what the value should be.
0
Comment
Question by:thejackal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
Michael_OReilly earned 20 total points
ID: 2566993
Countless ways to do this ... handiest (and VERY common way of doing it (coming from C history, and by now a programing idiom) probably being the following which also works fine in c++:

#include <stdio.h>
int x;
printf("Enter a number: ");
scanf("%d", &x);

or if u want a more standard c++ parlance:

int x;
cout << "Enter a number: ";
cin >> x;
cout << "You entered " << x << endl; // the endl means skip a line
0
 

Author Comment

by:thejackal
ID: 2574707
Thanks alot! :)
0
 
LVL 1

Expert Comment

by:Michael_OReilly
ID: 2575722
you're welcome
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question