Sunteți pe pagina 1din 5

ASSINGMENT 1- SME 1013 Exercise 1 /*My Program start here*/ #include<stdio.

h> main () { int b, e, i, j, k, l; float a, c, d, f, g, h; Display value on the screen a=0.5; printf("a = %f \n\n", a); This floating-point constant is valid.. Display value on the screen This decimal integer constant is invalid because illegal character (,) Answer

b=27,822; printf("b = %d \n\n", b);

c=9.5e12; printf("c = %f \n\n", c);

Display value on the screen This floating-point constant is valid.

d=9.3e-12; printf("d = %f \n\n", d);

Display value on the screen This floating-point constant is valid.

e = 1234567; printf("e = %d \n\n", e);

Display value on the screen This decimal integer constant is valid.

Display value on the screen f = .9; printf("f = %f \n\n", f); This floating-point constant is valid.

g = 0.8E+0.8; printf("g = %f \n\n", g);

This floating-point constant is invalid because exponents must be an integer quantity (it cant contain a decimal point).

h = 0.8E 8; printf("h = %f \n\n", h);

This floating-point constant are invalid because illegal character (blank space) in the exponent.

i = 0515; printf("i = %d \n\n", i);

Display value on the screen This octal integer constant is valid.

j = 018CDF; printf("j = %d \n\n", j);

This numerical values are invalid because illegal character (8), ( 8 is not in the octal integer constant). This numerical values are invalid because illegal character (G), ( G is not in the Hexadecimal integer constant).

k = 0XDEFG; printf("k = %d \n\n", k);

l = 0x87e3ha; printf("l = %d \n\n", l);

This numerical values are invalid because illegal character (h), (h is not in the Hexadecimal integer constant).

Exercise 2 /*My Program start here*/ include<stdio.h> main() { Answer

int i=8, j=5; float x=0.005, y=-0.01; char d='d'; x + y; printf("x + y = %f \n\n", x + y);

i % j + 2; printf("i % j + 2 = %d \n\n", i % j + 2);

j+i*x; printf("j+i*x = %f \n\n", j+i*x);

(j+i) * x; printf("(j+i) * x = %f \n\n", (j+i) * x);

j/i; printf("j/i = %d\n\n",j/i);

-(i+j); printf("-(i+j) = %d \n\n", -(i+j));

2*((i/5)+(4*(j-3))%(i+j-2)); printf("2*((i/5)+(4*(j-3))%(i+j-2)) = %d \n\n",2*((i/5)+(4*(j-3))%(i+j-2)));

j + (int)(x); printf("j + (int)(x) = %d\n\n",j + (int)(x)); d; printf("d =%c\n\n", d);

++d; printf("++d =%c\n\n", ++d); }

Exercise 3 /*My Program start here*/ #include<stdio.h> #include<math.h> main() { int i=8, j=5; float x=0.005, y=-0.01; abs(i-2*j); printf("abs(i-2*j) = %d\n\n\n", abs(i-2*j)); Answer

fabs(x+y); printf("fabs(x+y) = %f\n\n\n", fabs(x+y)); ceil(x+y); printf("ceil(x+y)= %f\n\n\n", ceil(x+y)); floor(x); printf("floor(x) = %f\n\n\n",floor(x)); sqrt(x*x + y*y); printf("sqrt(x*x + y*y) = %f\n\n\n", sqrt(x*x + y*y)); log(x); printf("log(x) = %f\n\n\n", log(x)); pow(x-y,3.0); printf("pow(x-y,3.0) = %f\n\n\n", pow(xy,3.0)); sin(x-y); printf("sin(x-y) = %f\n\n\n", sin(x-y)); }

S-ar putea să vă placă și