Exercise 4
Exercise 4
counter =2;
Do{ 5. Identify the errors and rewrite the correct program
if(counter%2==0){
printf(“%d\n”,counter); 1 #include <stdio.h>
} 2
counter+=2; 3 main(){
}While(counter<100); 4 int x,y,z;
5 x=val(1,4);
2. Identify the errors and rewrite the correct program 6 y=val(10,x);
7 z=val(y,15);
1 #include <math.h> 8 printf(“x=%d\ny=%d\nz=%d”,x,y);
2 main(){ 9 }
3 int i,j,k; 10
4 double sum 11 int val(int a, int b){
5 k=0;i=2; 12 int i, func=0;
6 do{ 13 for(i=0,i<=10,i++);
7 j=k-1; 14 func+=i;
8 sum+=abs(j); 15 Return(func);
9 i++; 16 }
10 while(i!=0)
11 printf(“sum=%f”,sum);
12 }