#include
void
printarr(int
a[]);
void
printdetail(int
a[]);
main()
{
int
a[5];
for
(int
i = 0;i<5;i++)
{
a[i]=i;
}
printdetail(a);
}
void
printarr(int
a[])
{
for
(int
i = 0;i<5;i++)
{
printf("value in array %d\n"
,a[i]);
}
}
void
printdetail(int
a[])
{
for
(int
i = 0;i<5;i++)
{
printf("value in array %d and address is %8u\n"
,a[i],&a[i]);
}
}
void
print_usingptr(int
a[])
{
int
*b;
You can write a C++ fib pro using arrays but the problem is the prog becomes very complicated since u need to pass the next adding value in an array.....
A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.
yes
int array[10] = {...}; for (int i = 0; i < 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }
how to write a program that counts automorphic number from 1 to 999
No.
You can write a C++ fib pro using arrays but the problem is the prog becomes very complicated since u need to pass the next adding value in an array.....
A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.
yes
int array[10] = {...}; for (int i = 0; i < 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }
Yes. Use cin and/or getline to read the formatted data into an array, compute the average then output the result using cout.
truzi i Ghal
Put all the values in an array, iterate through the array with a for loop, sum all the values, then divide by the count of the values.
Java doesn't have pointers. C++ has pointers.
how to write a program that counts automorphic number from 1 to 999
To determine if an array is symmetric, the array must be square. If so, check each element against its transpose. If all elements are equal, the array is symmetric.For a two-dimensional array (a matrix) of order n, the following code will determine if it is symmetric or not:templatebool symmetric(const std::array& matrix){for (size_t r=0 ; r
If the array is dynamic then use a vector instead of an array. You can then use the vector::erase() function to delete an element or a range of elements. Remember that if the vector contains pointers to unshared memory, then you must release the pointer before erasing the element containing that pointer. If the array is static then you cannot delete elements. The assumption with static arrays is that you will neither add nor delete, you will only modify existing elements. However, you can emulate a deletion by shunting elements to the left, and keeping track of how many used elements there are (which must always be less than or equal to the upper bound plus one). Again, if the array contains pointers to unshared memory, you must release the pointer before shunting elements. You can also do the same thing with dynamic C-style arrays, but once you've shunted elements to the left you can reallocate the array with the new size to physically delete the final element.