Senin, 16 November 2009

Latihan-latihan

Soal no.1

#include
void main()
{
int I,N;
N=45;
I=1;
while(I<=5)
{
printf(“\n%i”,N);
N=N+5;
I=I+1;
}
}

N=45 I=1 I<=5 Y/T Cetak N N=N+5 I=I+1
45 1 1<=5 Y 45 50 2
50 2 2<=5 Y 50 55 3
55 3 3<=5 Y 55 60 4
60 4 4<=5 Y 60 65 5
65 5 5<=5 Y 65 70 6
70 6 6<=5 T

Output : 45 50 55 60 65

Soal no.2

#include
void main()
{
int I,N;
N=45;
I=1;
while(I<=5)
{
N=N+5;
I=I+1;
}
printf(“\n%i”,N);
}

N=45 I=1 I<=5 Y/T N=N+5 I=I+1 CetakN
45 1 1<=5 Y 50 2
50 2 2<=5 Y 55 3
55 3 3<=5 Y 60 4
60 4 4<=5 Y 65 5
65 5 5<=5 Y 70 6
70 6 6<=5 T

Output : 70

Soal no.3

#include
void main()
{
int I,N;
N=45;
I=1;
while(I<=5)
{
N=N+5;
printf(“\n%i”,N);
I=I+1;
}
}

N=45 I=1 I<=5 Y/T N=N+5 Cetak N I=I+1
45 1 1<=5 Y 50 50 2
50 2 2<=5 Y 55 55 3
55 3 3<=5 Y 60 60 4
60 4 4<=5 Y 65 65 5
65 5 5<=5 Y 70 70 6
70 6 6<=5 T

Output: 50 55 60 65 70

Soal no.4

#include
Void main()
{
int I,N;
N = 10;
I = 10;
While (N<=100);
{
N = N + I
Printf (“\n%i,”N);
I = I + 5;
}
}

N=10 I=1 N<=100 Y/T N = N + 1 Cetak N I = I + 5
10 10 10<=100 Y 20 20 15
20 15 15<=100 Y 35 35 20
35 20 20<=100 Y 55 55 25
55 25 25<=100 Y 80 80 30
80 30 30<=100 Y 110 110 35
110 35 35<=100 T

Output: 20 35 55 80 110

Tidak ada komentar:

Posting Komentar