C Programming - Lecture 4: Input, Array and Boolean expressions

Input
We use to take input from the user scanf function. scanf function is to give at least two parameters. And another that addresses a string variable. Suppose we want to take an integer input
int num;
scanf ( "% d", & num);
The "% d" means that we want to input an integer. & Num num variable addresses with commas, and then we wrote. Now run the program at the time of the lainataya the program will wait for an integer.
For example, from the keyboard to enter a number with the 123. 123 the number of variables in the program will then num.Thus, we can input a decimal number. In that case, we will use% f and type of variable as a parameter to a float.
![]() |
| Example of Input |
float price;
scanf ( "% f", & price);
If we want to take the value of two at a time like this can be helpful to write
int num;
float price;
scanf ( "% d% f", & num, & price);
First, we have the first of% d int variables that must be addressed in this case is & num. Then there must be the address of the variable% f, for which our float, which is the & price.
Array - initial consultation
Our case is similar to several variables, then we use the array. Let's take our 100 for the number of variables.
If we can be helpful to declare variables 100
int number0, number1, number2, ...., num ninety nine;
Thus, the use is very difficult to declare bhariyebala. So we want to make it easy.
int number [100];
![]() |
| Example of Array |
Thus, if we get a place to number 100. And will name their number [0], number [1], number [2], .... , Number [99] Thus,. [] The number of written inadeksa That meant that the number of What order. Indexing will begin from zero.
So if you want to keep 500 of the 3rd figure it would be for us to write,
number [2] = 500;
If you'd like to write 170 100th sandhye tahalai it will write Rabies
number [99] = 170;
We can take any number of inputs. Suppose I want to take the number 5. Similarly, it will address & number [4].
scanf ( "% d", & number [4]);
For now, we'll talk to me about the array.
Boolean expressions
We know that there is a value expression. The value of expression is not just a number or some other true (true) or false (false) Boolean expressions as they may be these two values.
Suppose we assign an int variables, 35, stood
int score;
score = 35;
![]() |
| Example of Boolean Expressions |
Now, if we write
score> 30
Then we heard an expression whose value buliyara true. Again, if we write
score> 40
This value tahalai false.
Boolean expressions can be ghathana consisting of one or more smaller expressions, can be combined with AND or OR yegulake. OR is written in language such as C.
AND they are written with
&&
A.
If we likhi
(Score> 20) && (score <33)
Since we are
&&
I use this expression to be true must be true for the two eksaprasana. If the program finds two separate expression value is true, then you will see both of them.
As a eksaprasana
(Score <33)
If false, false values ??of our whole eksaprasanera.
Again, if we are
Use kari
(Score> 20) (Score <33)
If you
(Score> 20)
The value of true and
(Score <33)
Praro expression of true, false, will be due.
Therefore
&&
Combined with more than one expression to be true, the value of all expression must be true.
Combined with more than one expression to be true, that if true, would be an expression.




No comments: