How do you run a program in gdb Why doesnt C provide the sam
Solution
Q3: A PART: To run a program in gdb, following steps are followed:
   Assume that our c file is abc.c
    Step 1: Compile the code with the command : $ cc -g abc.c
    Step 2: Launch the gdb with the command : $ gdb a.out
    Step 3: Now, set up a break point using the command : break 11 (11 is the line number in the file)
    Step 4: Now, run the program with command run[args] or just run
   
B PART: Why doesn\'t C provide the same kind of bounds-checking on arrays that Java does?
    C is a simple program. bounds checking is any method of detecting whether a variable is within some bounds before it is used. In C, there is no structure of arrays provided, we just take consecutive addresses and name them as a group to be an array. So, to check whether the accessed location is within those addresses or not is taken as another single instruction. This happens everytime an array is used. If the array is used a zillion times, this redundant bound checking also happens a zillion times which is just a waste of time. But in Java, the array length is saved in a constant buffer using array.length attribute. This makes bound checking in java efficient than C does.
---------------------------------
 Q4: CON : If we use smart objects for a string as in java, there is an advantage of encapsulation. This means, we can retain some common properties of a string within the object without having to recalculate. This is not possible with the strings stored in the dumb arrays.
PRO : Using strings as arrays, we can refer to each character of the string individually and process it and also can delete it without affecting other characters.

