Sunteți pe pagina 1din 2

II.

1.
Subscript Subscripted variable
1. Cell number of array used under 1. Name of an array is called as
square bracket ([]) is called as subscripted variable.
subscript of an array. e.g. arr[6], here arr is the
e.g. arr[6], here 6 is the subscript of subscripted variable.
array arr

2.
char a[5] int a[5]
1. It represent the array having name a 1. It represent the array having name a
of character type which can store 5 of integer type which can store 5
characters at different position integers at different position starting
starting from 0 to 4. from 0 to 4.

3.
Ordinary variable Array variable
1. An ordinary variable hold a single 1. An array variable can hold multiple
value. values.
2. An ordinary variable do not have any 2. An array variable is always declared,
subscript. initialized, and accessed using
subscript.

4.
String a[5] String a[]
1. It will store 5 string values 1. It can store any number of string
values.
2. Number of string values are fixed i.e. 5 2. Number of string values are not fixed
so no need to use length function so length function is used to find total
number of element present in an
array.

5.
Sorting Searching
1. The process of arranging the elements 1. It is process to determine whether a
of an array in a specific order is known given item is present in the array or
as sorting. not.
2. Selection and bubble sort can be used 2. Linear and binary searching
to sort an array. techniques can be used to search an
item in an array.
7.
Sequential sort Bubble Sort
1. In sequential sort, we find the 1. In bubble sort, we compare two values
minimum value in the array then swap and put the largest value at largest
it to position. In the next step leave index and repeat the step until the
the first value and find the minimum values of array is sorted.
value within remaining values. Then
swap it with the value of minimum
index position.

III.
1. Here m [1] =4, m [2] =6 and the ASCII value of whitespace i.e. ‘ ‘ is 32.
Therefore, m [1] + ‘ ‘+ m [2] = 4+32+6=42
Hence, output will be: 42

2. Here, a [0] = 23. Since, a [1] =4. Therefore, c=a[0]+a[1]=23+4=27


Hence, output will be: Sum=27

3. Here, a [2+1] means a [3]. Therefore, a[3]=12


Hence, output will be: 12

4. Here, declaration of the array a [4] is illegal. It should be int a[]={2,4,6,8};


When i = 0, test condition i < = 1 i.e. 0 < =1 is true.
Therefore, s=a[i]+a[3-i]=a[0]+a[3-0]=a[0]+a[3]=2+8=10
Hence, s=10
When i = 1, test condition i < = 1 i.e. 1 < =1 is true.
Therefore, s=a[1]+a[3-1]=a[1]+a[3-1]=a[1]+a[2]=4+6=10
Hence, s=10
When i = 2, test condition i < = 1 i.e. 2 < =1 is false. Loop will be terminated.
Therefore, output will be: 10
10

S-ar putea să vă placă și