main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Answers were Sorted based on User's Feedback
Answer / lalitha
size of char is 1
and size of int is 2/4 depending on n-bit m/c
| Is This Answer Correct ? | 24 Yes | 6 No |
Answer / lalitha
@ guest
if we give sizeof(char) or
char ch;
sizeof(ch) the result is 1
and if we give sizeof('1)
sizeof('c') the result is 2/4
does it treat as AsCII value which is an interger?????
how come????
| Is This Answer Correct ? | 12 Yes | 1 No |
Answer / anil
for the above question the give options are not suitable
it gives the out put as:
1, 2
| Is This Answer Correct ? | 9 Yes | 6 No |
Answer / praneeth
In C programming language
The size of character literal is size of int. (2 or 4)
ex:: sizeof('A') == sizeof(65)
the size of char is 1
ex:: char ch = 'a';
sizeof(ch) == 1
I hope U understand....
praneeth
| Is This Answer Correct ? | 7 Yes | 4 No |
Answer / ab
answer can be both a and d part..its compiler dependent...
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / sai
Answer will be (2,2).
EXPLANATION:
In the above printf() statement the size of the char is 2 because
it will takes ASCII value for 'c' because "%d" is the integer specifier.
| Is This Answer Correct ? | 3 Yes | 0 No |
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
Develop a routine to reflect an object about an arbitrarily selected plane
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }
void main() { char ch; for(ch=0;ch<=127;ch++) printf(“%c %d \n“, ch, ch); }
#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }
1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.
plz send me all data structure related programs
Is the following code legal? struct a { int x; struct a *b; }
main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);
why array index always strats wuth zero?
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)