Want this question answered?
Declare 2 pointer variable of the same type and assign the address of the variable to them and then increment one of them. Find the difference between the above 2 pointers using a type cast. This will be the size of the variable. Eg: double i; double * p = &i; double * q= p; p++; cout<<(int)p-(int)q<<endl;
If you assign -1 to a unsigned variable it will contain the biggest number its able to hold. For example if you assign -1 to a unsigned int it will be 4294967295 as its the biggest number a unsigned int can hold.
A double essentially is an int but with a decimal. For example, 4.5 is a double. But the int value of that would be 4
Some smart compilers will not allow you do that. If you managed to do that, there are couple different results, the most predictible is decimal part will be cut, only what left will be shown. If it exceed the amount of memory reserved for int (double > float > int), it will show the maximum or positive or negative value for int type, or it will shifted by some amount from the maximum or minimum.
In C: int pass_mark; pass_mark = 45; In C++: int pass_mark {45};
By type casting since int is of larger bits than short s=(int)i;
Declare 2 pointer variable of the same type and assign the address of the variable to them and then increment one of them. Find the difference between the above 2 pointers using a type cast. This will be the size of the variable. Eg: double i; double * p = &i; double * q= p; p++; cout<<(int)p-(int)q<<endl;
No, but 'typedef int a;' is possible, it defines the type 'a'.
If you assign -1 to a unsigned variable it will contain the biggest number its able to hold. For example if you assign -1 to a unsigned int it will be 4294967295 as its the biggest number a unsigned int can hold.
A double essentially is an int but with a decimal. For example, 4.5 is a double. But the int value of that would be 4
Some smart compilers will not allow you do that. If you managed to do that, there are couple different results, the most predictible is decimal part will be cut, only what left will be shown. If it exceed the amount of memory reserved for int (double > float > int), it will show the maximum or positive or negative value for int type, or it will shifted by some amount from the maximum or minimum.
In C: int pass_mark; pass_mark = 45; In C++: int pass_mark {45};
double mean(int list[], int arraySize) { double result=0; for(int i=0; i<arraySize; ++i ) result += list[i]; return(result/size); }
Possible. Example: void mat_mul (int m, int n, int l, const int **a, const int **b, int **c) { int i, j, k; double sum; for (i=0; i<m; ++i) { for (j=0; j<l; ++j) { sum= 0; for (k=0; k<n; ++k) { sum += a[i][k] * b[k][j]; } c[i][j]= sum; } }
For this you need two variables, a and b. Generate the first number and assign it to a. Generate the second and assign it to b. If b is greater than a, assign b to a. Generate the third number and assign it to b. If b is greater than a, assign b to a. Print a. A better method is to use the following function to determine the largest of any two values: int max (int x, int y) { return x>y ? x : y; } Once you know the largest of any two values you can easily determine the largest of any three values with a nested call: int max_of_three (int a, int b, int c) { return max (max (a, b), c)); } Note that we determine the largest of a and b first and then pass that value to a second call along with c, thus establishing the largest of all three. To determine the largest of n values, store the numbers in an array and pass the array and its length to this function: int max_of_n (int a[], size_t n) { int m = a[0]; // store first value while (--n) if (a[n]>m) m=a[n]; // update m whenever a[n] is greater return m; }
You cannot physically convert variables of one type to another type, you can only cast them to create a new type (a new variable), providing the new type is covariant with the existing type. int i = 100; // int variable int* p = &i; // pointer to int The indirect value of p is i (100) while the direct value of p is the address of i. And because p is a variable, it has an address of its own. Thus converting the pointer p to an int can be done in one of three ways: int j = *p; // assign indirect value of p to j (thus j==100). int k = (int) p; // cast the address stored in p and assign to k (k==address of i) int l = (int) &p; // cast the address of p and assign to l (l==address of p)
int,float char,double ,long int,unsined int lots of others..