In: Computer Science
1) What are import libraries ? 2) What commands are found in the #include library that we will use ? 3) What is syntax ? 4) What does the computer do when it encounters a statement that Declares a variable ? 5) What are the byte sizes for int, double and char data types ? 6) Why is an int variable only able to store a range of values from approx -2.1 billion to +2.1 billion ? 7) What is PEMDAS ? How is it also important when doing math in a computer program ? 8) Is the ‘=’ sign the same for math and programming ? Explain your answer. 9) What happens when you Assign a value to a variable ? How does it work ? 10) What is variable Initialization, is it necessary in JAVA ?
The answer to the above question is:-
1.) Generally, in our code, there will be some cases where we want to print something on the screen. In that case, we will directly use System.out.print("hello");. Here we are calling "System.out.print()" function to print "hello" but we will not write the code for that function because it is "standard library function". Standard library functions are the functions to which we will not write the code but we will use their functionality directly by importing that package or class where that method will be present.
2.) for example in c we will use # include<stdio.h> After
we include the header fIle, the C/C++
compiler goes to the standard library (generally it is available in
tc/ lib) and searches for the header fIle there. When it finds the
header fIle, it copies the entire header file content into the
program where the #include statement is written.
3.)Syntax refers to the foundations that specify the proper combined sequence of symbols which will be accustomed type a properly structured program employing a given programing language. Programmers communicate with computers through the properly structured syntax, linguistics and synchronic linguistics of a programing language.
4.)Variables are used to store information, they also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. A variable can be thought of as a container to store information. The sole purpose is to label and store the data. This data can be used throughout the program. When a variable is declared some memory is allocated in the computer.
5.) Byte sizes:
int is 4 bytes
double is 8 bytes,
char is 2 bytes.
6.)Generally, for storing a number in billion it requires a memory of 4 bytes so int can store the value within 2.1 billion range.
7.)PEMDAS:- 5+3/5+3(4*5) how to calculate the value i,e., which operation should be done first. To answer those questions we will follow PEMDAS.
order of evaluation of the expression follows as:-
1.)P:- Parenthesis first
2.) E:- Exponents(i,e., powers and squares roots) next.
3.) M D:-Multiplication and Division (left to right), here multiplication and division rank equally so they go from left to right.
4.) A S:- Addition and Subtraction(left to right). Here addition and subtraction rank equally so they go from left to right.
8.)The usage of '=' is not the same in programming and math. In programming '=' is used to assign something to a variable.
Whereas in maths '=' is used to show two quantities are equal.
9.)Variable is a memory location so when we assign a value to a variable the value is stored in that memory location and we can access the value by that variable.
10.)Variable initialization means assigning a value to a
variable. In java, variable initialization is some times necessary
and sometimes not necessary. For instance and the boolean variable,
it is not necessary to initialize. But for local variables, it is
necessary to initialize them. Otherwise, the compiler will show an
error message.
If any problem in understanding plz comment.