Wednesday, July 17, 2013

Turbo C: Variables and User Input

Getting input value

In every program, variables are declared and used for the user inputs. From my previous post, we already know how to declare variables, but those variables are static or cannot be changed when we run our program.


This time, we are going to create a program that will let the user to input the value. This basic program will ask the user to enter a value that will be set to our variables, and then the program will get the sum of two inputs.

Code:




By using the scanf(“%d”, &x) we are able to get the user input. (“%d”, &x) will get an integer value of the input and will be assigned in variable x.




No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...