#define DIM( array, type) sizeof(array)/sizeof(type)
main()
{
int arr[10];
printf(“The dimension of the array is %d”, DIM(arr,
int));
}
Answer / susie
Answer :
10
Explanation:
The size of integer array of 10 elements is 10 *
sizeof(int). The macro expands to sizeof(arr)/sizeof(int) =>
10 * sizeof(int) / sizeof(int) => 10.
Is This Answer Correct ? | 3 Yes | 2 No |
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)
main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4
Is this code legal? int *ptr; ptr = (int *) 0x400;
How we print the table of 3 using for loop in c programing?
String reverse with time complexity of n/2 with out using temporary variable.
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }
What is your nationality?
main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O
main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }
4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }