ALGORITHM and PROGRAMMING (part.6)

REVIEW

Sistem pemprogramman sebarnya hanya ada tiga langkah yaitu : Input – Process – Output

Process terdiri dari beberapa macam :

-Selection : If, Else-If, Nasted If, Switch Case

-Repetition / Looping : For, While, Do-While

-Strorage (belum diajarkan)

Coding segitiga tengahnya kosong :

#include<stdio.h>

int main(){
int n,a,b;
scanf(“%d”, &n);
fflush(stdin);
for(a=1;a<=n;a++){
for(b=1;b<=a;b++){
if(b==1||a==b||a==n){
printf(“*”);
}
else{
printf(” “);
}
}
printf(“\n”);
}
getchar();
return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *