Program Deret

Contoh 1 :

#include<stdio.h>

int main()

{

  int n,a,b,c;

  printf(“Input maks deret = “);

  scanf(“%d”,&n);

    for (a=1;a<=n;a++) {

    for (b=n;b>=a;b–) {

         printf(” “);

         }

    for (c=1;c<=a;c++) {

         printf(“* “);

         }

         printf(“\n”);

         }

    for (a=1;a<=n;a++) {

    for (c=1;c<=a;c++) {

         printf(” “);

         }

    for (b=n;b>=a;b–) {

         printf(“* “);

         }

         printf(“\n”);

         }

return 0;

}

Output

Input maks deret = 5

*

* *

* * *

* * * *

* * * * *

* * * * *

* * * *

* * *

* *

*

contoh 2 :

include<stdio.h>

int main()

{

int n,a,b,c;

   printf(“Input maks deret = “);

   scanf(“%d”,&n);

        for (a=1;a<=n;a++) {

        for (c=1;c<=a;c++) {

              printf(” “);

              }

        for (b=n;b>=a;b–) {

              printf(“V “);

              }

               printf(“\n”);

               }

 

          for (a=1;a<=n;a++) {

          for (b=n;b>=a;b–) {

                printf(” “);

                }

           for (c=1;c<=a;c++) {

                 printf(“V “);

                 }

                 printf(“\n”);

                 }

return 0;

 

Output

Input maks deret = 5

V V V V V

V V V V

V V V

V V

V

V

V V

V V V

V V V V

V V V V V

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: