-
-
Save iCHAIT/2d1d4c8b0a61fb6f6d4e57eaae53f6cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() { | |
// your code goes here | |
char *s1, *s2; | |
printf("%d%d", sizeof(s1), sizeof(s2)); | |
return 0; | |
} | |
// codechef IDE gives answer - 4,4 | |
// my machine gives - 8,8 | |
// correct answer - 4,2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <stdio.h> | |
# include <stdlib.h> | |
int main() | |
{ | |
extern int i; | |
printf("\n%d",i); | |
return 0; | |
} | |
int i=20; | |
// how come this works? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <stdio.h> | |
int main() | |
{ | |
int i=4; | |
switch(i) | |
{ | |
default: | |
printf("\ndefault\n"); | |
case 1: | |
printf("\ncase 1\n"); | |
break; | |
case 2: | |
printf("\ncase 2\n"); | |
break; | |
case 3: | |
printf("\ncase 3\n"); | |
break; | |
} | |
return 0; | |
} | |
/* gives output - | |
default | |
case 1 | |
how? | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <stdio.h> | |
int main() | |
{ | |
int x=10,y=20,z=5,i; | |
i = x<y<z; | |
printf("\n%d",i); | |
return 0; | |
} | |
// how does this gives answer 1? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int arr[] = {2,3,4, 1,6}; | |
printf("\n%d\n%d", arr, sizeof ( arr )); | |
return 0; | |
} | |
//output - 123445, 20 | |
// books gives 10 |
Author
iCHAIT
commented
Apr 9, 2016
- how would you dynamically allocate a 1D array?
- how would you dynamically allocate a 2D array?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment