Disadvantages of C are:
1. There is no runtime checking.
2. There is no strict type checking (for ex:we can pass an integer value for the floating data type).
3. As the program extends it is very difficult to fix the bugs.
C is a middle level language so it can be used for interaction with the hardware easily, at the same time it can interact with the user...
It uses the POP (Procedure Oriented Programming) approach which is its major disadvantage..
Advantages include its interaction with hardware, easy to learn, code is secure
Compact and efficient. Many people find it rather very difficult to work with.
Another opinion:I do not think C has any disadvantages but others think differently. The correct answer that you need is the answer your teacher wants, ask your teacher or read your text book.Another answer:
C has been made by real programmers, for real programmes. Just like UNIX. If you think that C (or unix) is not your cup of tea, then most likely you are right -- don't try to force.
Advantages:
1. You can use one name for similar objects and save then with the same name but different indexes.
2. Arrays are very useful when you are working with sequances of the same kind of data (similar to the first point but has a different meaning).
3. Arrays use reference type and so.
Disadvantages:
1. Sometimes it's not easy to operate with many index arrays.
2. C environment doesn't have checking machism for array sizes.
3. An array uses reference mechanism to work with memory which can cause unstable behaviour of operating system (unless special methods were created to prevent it) and often even "blus screen" and so on.
arrays itself are pointers in a sense arr[0] is the address where value is stored at address arr[0] 0 is the index pointers of course are used with reference to the address of the variable instead of the value itself which helps memory management.pointers can return more than one value from a function whatever changes happen in the called function are reflected to the function declared in main for example in array we scan values first then use another for to print them or perform operations in pointers the *ptr returns the value for eg ptr=&variable *ptr will return the value of the variable wherever required ptr is the address eg 5000 to go to next value we do ptr++ which returns the next value in the list just the way we treat a list in array if it is int type variable next variable wil contain 5002 so *5002(*ptr) will return the next value
The Advantages of using an array: 1. Static and compile time memory allocation 2. Contigious Memory allocation 3. Random access is possible based on Index 4. Gives the base address when array name is specified and hence easy to pass by pointer Disadvantages: 1. Run time memory increment or decrement is not possible so if not used properly then it can lead to memory wastage or to out of bound access 2. Run time no boundry check mechanism is provided
The disadvantages of arrays in C are:
You can get around these problems by dynamically allocating storage using malloc, and checking for out-of-bounds access (a dynamic array).
arrays are very very useful in c++
for example if you need to store marks of 100 students..... u will have to make 100 int type data types............ so long.... but arrays can do the same work in a few seconds.....
its prototype is like this..
void main ()
{
int a[100]; // 100 here is the size of the array
int i;
for(i=0;i<100;i++)
{
cin>>a[i];
}
}
this will take data of all 100 students in an array form....
..... how will PC store these data....
subscripts 0 1 2 3 5...... 100
data 9 4 7 4 6...... 8
it will be like
a[0]= 9
a[1]= 4
a[2]= 7
a[3]= 4
a[4]= 6
....
a[100]= 8
DISADVANTAGES....
..... THERE ARE NO DISADVANTAGES ABOUT ARRAYS IN C++
ARRAYS ARE THE HEART OF C++ AND OTHER PROGRAMING LANGUAGES.....
ARRAYS ONLY AND ONLY HAVE A LOTZZZ OF ADVANTAGES....... TIME CONSUMING, EASY..... ETC...
ARRAYS ARE THE BASIC OF C++.......
BUT SO FAR SEEN AS A STUDENT (ME) ARRAYS SOMETIMES BECOME BIG PROBLEM.... FOR EXAMPLE IF I HAVE TO SWAP THE BIGGEST ELEMENT OF THE ARRAY WITH 1.........
I WILL HAVE TO CREATE AN ALGORITHM TO FIND A WAY TO DO IT......
BUT IN SIMPLE DATA TYPE.... I COULD DO IT AS...
A=1...
.....
HOPE IT WAS USEFUL.....
- Sundeep Singh
The main Advantages of array :
1. You can use one name for similar objects and save then with the same name but different indexes.
2. Arrays are very useful when you are working with sequances of the same kind of data (similar to the first point but has a different meaning).
3. Arrays use reference type and so.
The main advantages of pointers are :
1.) Function cannot return more than one value. But when the same function can modify many pointer variables and function as if it is returning more than one variable.
2.) In the case of arrays, we can decide the size of th array at runtime by allocating the necessary space.
3.) In the case of pointers to classes, we can use polymorphism and virtual classes to change the behavior of pointers to various types of classes at runtime
The number of elements that will be stored in arrays should be determined ahead of time. A static array is one that does not change. In an array, insertion and deletion are tough. Memory waste occurs when more memory is allocated than is required.
To learn more about data science please visit- Learnbay.co
The disadvantages of an array are......
(i) Memory wastage..
(ii) We cannot insert any element in between an array..
(iii) Any element cannot be inserted in between..
By using array we can short the program otherwise it will be very lengthy, we can use it for a group of elements having sane data type
The lowest subscript of an array in C, or C++ is 0.
#include main() { int array[100], minimum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d",&size); printf("Enter %d integers\n", size); for ( c = 0 ; c < size ; c++ ) scanf("%d", &array[c]); minimum = array[0]; for ( c = 1 ; c < size ; c++ ) { if ( array[c] < minimum ) { minimum = array[c]; location = c+1; } } printf("Minimum element is present at location number %d and it's value is %d.\n", location, minimum); return 0; }
Wright a 'C' program for storage representation of 2-D array.
Option 1) Use a temporary variable: int x = array[i]; array[i] = array[i+1]; array[i+1] = x; Option 2) Use bit operators: array[i] ^= array[i+1] ^= array[i];
A multidimensional array in C or C++ is simply an array of arrays, or an array of an array of arrays, etc. for however many dimensions you want. int a; // not an array int a[10]; // ten int a's int a[10][20]; // twenty int a[10]'s, or 200 int a's int a[10][20][30]; // and so on and so forth...
A string in C is stored in a 1 dimension array so an array of strings is simply a two dimension array.
The lowest subscript of an array in C, or C++ is 0.
Heres something i whipped up in a hurry... This uses the Bubble Sort method found (related links) #include <iostream> using namespace std; int main(int argc, const char* argv) { int arraysize = 5; //Unsorted array size int array [] = { 5, 3, 4, 2, 1 }; //The array of numbers itself //Display the unsorted array cout << "Before: {"; for (int c=0; c <= arraysize; c++) { cout << array[c]; if (c != arraysize) { cout << ","; } } cout << "}" << endl; //Acctually sort the array int tmp=0; //Used for swaping values for (int loop=0; loop <= (arraysize - 1); loop++) { for (int c=0; c <= (arraysize - 1); c++) //The sort loop { if (array[c] > array[c + 1]) { //Swaps the two values in the array tmp = array[c]; array[c] = array[c + 1]; array[c + 1] = tmp; //Cleanup tmp = 0; } } } //Display the sorted array cout << "After: {"; for (int c=0; c <= arraysize; c++) { cout << array[c]; if (c != arraysize) { cout << ","; } } cout << "}" << endl; return 0; }
You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.
The syntax to access a particular element in an array are the same in both languages: For example: assume array is an array of 10 int(egers): to get the first element: array[0] (both are 0 based indexing] int i = 0; while (i < array.Length) { // do something to array[i] } int i = 0; int length = sizeof(array) / sizeof(int); while (i < length) { // do something to array[i] } However, an array in C# is also enumerable (C does not have this feature) in C#, you may loop thru the array by: foreach (int number in array) { // do something to array[i] } Plus, C# is an Object-Oriented Language, so that an array may be of some object types, not just those primitiives data types in C: object[] objectArray; // any object derived from Object may be placed into objectArray, not just struct. In another variation, an array may be of Delegate type in C#(sort of like function pointers in C)
If the array consists of r rows and c column, and the total number of cells in the array are n = r*c, then r*c = n and c*r = n so that r*c = c*r : which is commutativity of multiplication.
#include main() { int array[100], minimum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d",&size); printf("Enter %d integers\n", size); for ( c = 0 ; c < size ; c++ ) scanf("%d", &array[c]); minimum = array[0]; for ( c = 1 ; c < size ; c++ ) { if ( array[c] < minimum ) { minimum = array[c]; location = c+1; } } printf("Minimum element is present at location number %d and it's value is %d.\n", location, minimum); return 0; }
cod a program student degree array in c language
No.
Wright a 'C' program for storage representation of 2-D array.
Option 1) Use a temporary variable: int x = array[i]; array[i] = array[i+1]; array[i+1] = x; Option 2) Use bit operators: array[i] ^= array[i+1] ^= array[i];
A multidimensional array in C or C++ is simply an array of arrays, or an array of an array of arrays, etc. for however many dimensions you want. int a; // not an array int a[10]; // ten int a's int a[10][20]; // twenty int a[10]'s, or 200 int a's int a[10][20][30]; // and so on and so forth...