Professional Documents
Culture Documents
CODE MANIA
Write the output of the following snippets.
1. main() { float me = 1.1; double you = 1.1; if(me==you) printf("equal"); else printf("not equal"); } 2.
main() { int i=-1,j=-1,k= 0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l, m); } 3.
{ int x=20; f(); printf(%d,x); getch(); return 0; } void f() { int j=20; j=*(&j+2); } 4. #include<stdio.h> #include<conio.h> int main() { int a[2][4]={3,6,9,12,15,18,21,24}; printf("%d %d %d",*(a[1]+2),*(*(a+1)+2),2[1[a]]); getch(); return 0; } 5. #include<stdio.h> #include<conio.h> int fun2(char *a,char *b) { for(; *a==*b;a++,b++)
if(*a=='\0') return 0;
char a[10]="date",b[10]="data"; fun2(a,b); getch(); return 0; 6. #include<conio.h> #include<stdio.h> void foo(int x) { int i=0; while(x) { x=x&(x-1); i++; } printf("%d",i); } int main() { int i=3;
#define min(a,b) ((a) > (b) ? (a) : (b)) int a, b; a = 10; b = 5; min(++a,b); printf("%d,%d,",a,b); min(++a,b+10); printf("%d,%d",a,b);
2.Write a program to print 1-100 and backward without using loops. 3.Write a C++ program to print out "Hello world" without using any '; 4. Write a program taking two integers from user and printing the addition of them, but the restriction that you are allowed to use only one variable (neither dynamic allocation nor use of array). 5.Write a program taking two integers from user and swapping their content, but the restriction that you are allowed to use only one variable (neither dynamic allocation nor use of array).