|Learn Computer Programming - Level one of C Programming (Part 04)|
Learn Computer Programming - Level one of C Programming (Part 04)
This is a encourage post to become start learning C programming, this is a last post, first we have to see the response about this post, then we will continue our contribution in it.
Work with fixed data for variables
How to declare variables in the previous episode we know. But what is the benefit of keeping data in variables within a program? How do I use the data? Before answering the question, let's run a program. Well, what program can run? Let's create a program so you can add any number as you like. At the very beginning, I have says that developing logic is more important then developing language. So let's do a program to make sum of two numbers.
Problems Processing Step :
- First we need to take three variables. Two variable is for input and other is for output.
- Giving two input from the user.
- Sum up.
Let's go to solve this problem with programming.
Now we'll analyze this program.
int a, b, c;
Through this line, three variables of int type are declared in the program, which are named a, b and c. In this type variable you must have an integer number.
printf(“\n Enter first value:”);
Through this line Enter first value: writing screen is shown.
A full number of inputs are being requested from the user through this line, which will be pressed through the user's keyboard button. The number that the user types in will be in a variable. By &a means the address of a. That is, through this statement, the compiler is informed that the number obtained will be kept in the address given for a.
printf(“\n Enter second value:”);
Through this line Enter second value: writing screen is shown.
Another integer input from the user through the line, which is being sought user will press the button on your keyboard. The number that the user will type in b variables.
The data stored in a and b addresses will be added through this line. Adding the sum found to the variable c is being set.
printf(“\n %d+%d is %d”, a,b,c);
The data stored in a, b, c through this line is being shown in the output.
Use of scanf () function:
Two numbers are added by the scanf () function without input. Let's run the program below.
By this program, we can add two numbers. But the problem is that here only we can add two numbers. To add a number later, our source program has to be changed again which is a very difficult task. So if we take input from the user to increase the efficiency of the program, we can add any two numbers instead of adding two digits.
You can not declare multiple variables by the same nameNow what if you want to add any three numbers? Take four variables or three? Think of yourself. Do you can multiplication or subtraction of two numbers? Hope you can.
Keyword is a special word used in the program. Each keyword has certain meanings and completes a specific task in the program.
Such as: auto, for, double, break, int, void, float etc. keywords. If you do programming, your idea about keywords will come. But one thing must be kept in mind that the name of the keyword must be written in a word. In other words, there can be no gaps in it. However, if two keywords are used in any program, then there will be a gap in the middle.
Please visit our post to see the full details about programming...
|Learn Computer Programming - Programming Idea (Part 01)||Click Here|
|Learn Computer Programming - Basic C Programming (Part 02)||Click Here|
|Learn Computer Programming - Level one of C Programming (Part 03)||Click Here|
|Learn Computer Programming - Level one of C Programming (Part 04)||Click Here|
Thanks for visiting.
Read Our other post. We hope you like it. Please leave a comment for improving any part in your sense.