how do i get a program to display the variable i entered using the printf and scanf commands.
how do i get a program to display the variable i entered using the printf and scanf commands.
try this:Originally posted by jobolikescake
how do i get a program to display the variable i entered using the printf and scanf commands.
PHP Code:
#include <iostream>
void main()
{
int i;
cin >> i;
cout << "The value of variable i is: " << i << endl;
cin >> "what";
}
Never end on learning~
here its using scanf(), printf()
Code:include <stdio.h> int main(){ int myInt; printf("enter an integer"); scanf("%d",&myInt); printf("you entered %d",myInt); return 0; }
Programming is a high logical enjoyable art for both programer and user !!
If you are programming in C++ then use cin and cout,Originally posted by jobolikescake
how do i get a program to display the variable i entered using the printf and scanf commands.
otherwise use fgets and printf (try to avoid the scanf function).
My mother always told me... scanf is bad..... very bad.
momma's boy!!!Originally posted by Monster
[My mother always told me... scanf is bad..... very bad. [/B]
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
i tried using the cout and cin but iostream.h for some reason produces anywhere from 3-33 errors so i just gave up on it, but i did get my program to work using the way moemen explained so im happy now....
thanks everyone for the help
Hooked On Phonics Didn't Work For Me!
This way it will work with cin and cout. It's very simple.Code:#include <iostream.h> int main() { int myInt; cout << "enter an integer"; cin >> myInt; cout << "you entered " << myInt; return 0; }
Last edited by Zewu; 07-08-2002 at 09:17 AM.