Solved

Easy C++ commands

Posted on 2000-02-28
3
181 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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

831 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