Write the output for the following C program
| #define p(a,b) (a+b)/2 main( ) { int x=4, y=9, h; x+=y++; y*=3; h=p(x,y); printf("%5d %5d %5d\n", x, y, h); } |
|---|
Output :-
_ _ _ 13 _ _ _ 30 _ _ _ 21
| #define p(a,b) (a+b)/2 main( ) { int x=4, y=9, h; x+=y++; y*=3; h=p(x,y); printf("%5d %5d %5d\n", x, y, h); } |
|---|
| #include< main( ) { int a, b; for (a=2, b=4; a < 100; b+=4, a*=3) { a+=b; printf("%4d", a); } } |
|---|
| main( ) int x=3, y=5, n; while (y < 30) { n=x+y; printf("%3d", n); x=y; y=n; } } |
|---|
| #define h(a , b) a > b ? a : b main( ) { int x=25, y=33, z=10; x+=3*y++; y*=3; z+=h(x,y); printf("%d \n %d\n %d \n", x, y, z); |
|---|
| #define f(x) x > = 0 ? "real" : "complex" main( ) { int a=2, b=7, c=7, d; d = (b*b-4*a*c); printf("\n d is a %s values", f(d)); } |
|---|
| main( ) { int a = 2, s = 0, j = 1; for ( ; a < 10; a+=3, j++) { s += a * a * a; printf("\n a = %d j = %d", a, j); } printf("\n j=%d a=%d s=%d", j, a, s); } |
|---|
| Output | ||
|---|---|---|
| a=2 | j=1 | |
| a=5 | j=2 | |
| a=8 | j=3 | |
| j=4 | a=11 | s=645 |
| #include< main( ) { int x = 6589; char z = '*'; float y = 8888.9935; printf("% -6.1f %3c\n", y, z); printf("% +5d % -3c\n", x, z); } |
|---|
| #include< mani( ) { int x = 789; float y = 6767.8787; printf("% -8d %+9.3f\n", x, y); printf("%+-6d % -15.2f\n", x, y); } |
|---|
| #include< mani( ) { char x = '&'; float y = 2134.627; printf("%3c %9.2f\n", x, y); printf("% -4c -7.0f\n", x, y); return(0); } |
|---|
| mani( ) { int a = 1235, b = -1888; float x = 2233.44, y = 4455.66; printf("% -6d % -6d\n", a, b); printf("% -8.2f % -10.1f\n", x, y); } |
|---|
| mani( ) { int a = 1235, b = -1888; float x = 2233.44, y = 4455.66; printf("%6d %6d\n", a, b); printf("%+8.2f %+10.1f\n", x, y); } |
|---|
| Statement | Output |
|---|---|
| printf("%15s",name); | SEETA_AUR_GEETA |
| printf("%10.6s",name); | _ _ _ _SEETA_ |
| printf("%9.3s",name); | _ _ _ _ _ _SEE |
| printf("% - 10.7s",name); | SEETA_A_ _ _ |
| printf("% - 12.9s",name); | SEETA_AUR_ _ _ |
| Statement | Output |
|---|---|
| printf("%4c",a); | _ _ _ Q |
| printf("%8c",a); | _ _ _ _ _ _ _ Q |
| printf("%5c",a); | _ _ _ _ Q |
| printf("% - 7c",a); | Q _ _ _ _ _ _ |
| printf("% - 4c",a); | Q_ _ _ |
| printf("% 12c",a); | _ _ _ _ _ _ _ _ _ _ _ Q |
| Statement | Output |
|---|---|
| printf("%f",a); | 32.289 |
| printf("%8.3f",a); | _ _32.289 |
| printf("%10.2f",a); | _ _ _ _ _32.29 |
| printf("% - 7.3f",a); | 32.289_ |
| printf("% - 11.3f",a); | 32.289_ _ _ _ _ |
| printf("% 11.4f",a); | _ _ _ _32.2890 |
| Statement | Output |
|---|---|
| printf("%d",a); | 3248 |
| printf("%7d",a); | _ _ _3248 |
| printf("%10d",a); | _ _ _ _ _ _3248 |
| printf("% - 6d",a); | 3248_ _ |
| printf("% - 9d",a); | 3248_ _ _ _ _ |
| printf("% - 15d",a); | 3248_ _ _ _ _ _ _ _ _ _ _ |
| #include< void main( ) { int i, j; for ( i = 1, j = 2; i < 5, j < 5; i++, j++) { printf("i = %d\t j = %d\n", i, j); printf("i = %d\t j = %d\n", i, j); } } |
|---|
| Output
|
|
|---|---|
| i=1
|
j=2
|
| i=1
|
|
| j=2
|
|
| i=2
|
j=3
|
| i=2
|
|
| j=3
|
|
| i=3
|
j=4
|
| i=3
|
|
| j=4
|
|
|
|
|
| #include< void main( ) { int i, j; for ( i = 1, j = 2; i < 5 , j < 3; i++, j++) { printf("i = %d \t j = %d\n", i, j); printf("i = %d\n j = %d \n", i, j); } } |
|---|
| Output
|
|
|
|---|---|---|
| i=1
|
j=2
|
|
| i=1
|
|
|
| j=2
|
|
|
|
#include< void main( ) { int a=2, j=1, s=0; for (j++, a=2; a<10; a + =3) { s=a*a; printf("a=%d \t j="%d s=%d\n" , a, j, s); } } |
|---|
| Output
|
|
|
|---|---|---|
| a=2
|
j=2
|
s=4
|
| a=5
|
j=2
|
s=25
|
| a=8
|
j=2
|
s=64
|
| #include< void main( ) { int i, j; for (i=1, j=2; i < 5; i++, j++) { printf("i = %d \t j = %d \n" , i, j); } } |
|---|
| |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| #include< #include< #include< main( ) { clrscr( ); int n; float p, r, si; p = 10000; r = 2; printf("\t Simple interest table\n"); printf("\n Year\t Interest(Rs.)\n"); for (n=1; n < =10; n++) { si = p*n*r/100; printf("%d\t%f\n", n, si); } return(0); } |
|---|
| Simple Interest Table | |
|---|---|
| Year | Interest(Rs.) |
| 1 | 200.000000 |
| 2
|
400.000000 |
| 3
|
600.000000 |
| 4
|
800.000000 |
| 5
|
1000.000000 |
| 6
|
1200.000000 |
| 7
|
1400.000000 |
| 8
|
1600.000000 |
| 9
|
1800.000000 |
| 10
|
2000.000000 |
© Blogger templates Newspaper III by Ourblogtemplates.com 2008
Back to TOP