Tutorial Basic - How To Make Two Pieces Of Regular Array And Procedure In C ++

in #utopian-io7 years ago (edited)

What Will I Learn?

  • You will learn C ++ programming language
  • You will learn the array functions
  • You will learn how to create arrays by procedure

Requirements

  • You need an understanding of C ++
  • You need basic programming
  • You need insight on arrays and arrays

Difficulty

  • Basic

Tutorial Contents

On this occasion I will give tutorials to my friends all about C + + programming language that discusses the array that will be compiled in the command pront and there are two types of arrays to be displayed ie simple arrays and arrays in the form of procedures, either directly in stage of manufacture and follow the steps below:

  • The first step is to create the file first and the author creates the file with the array name for the simple array and arrayprosuder for the array prosuder

  • The second step is that you have to write the syntax that the author will share and of course each syntax will be described in detail as below:

In this syntax serves as declaration to start typing syntax

#include <stdio.h>
void main()

In syntax this time function as integer number which is made on each declaration and its integer number there are 3 variables where variable a and b have number filled inside of sedangka variable c summing between both variable and for useful as repeat command as much as 5 times.

{
    int a[5]={1,2,3,4,5};
    int b[5]={1,2,3,4,5};
    int c[5],i;
    for(i=0;i<5;i++)

In this syntax serves as showing the results of the previous declaration

    {
        printf("[ A ] = %d       [ B ] = %d \n\n",a[i],b[i]);
    }
    printf("\n");
    for(i=0;i<5;i++)

In this syntax serves as a summation between array variables a and variable array b where the variable c which is the brain pemakainnya operator then followed by repetition then the results are displayed summing arrays a and b.

    {
        c[i]=a[i]+b[i];
    }
    for (i=0;i<5;i++)
    {
        printf("Penjumlahan Array A dan B adalah = %d\n",c[i]);
    }

}
  • After writing the above syntax then the program can be executed and the results as shown below:

image.png

All syntax for Array Here:

#include <stdio.h>
void main()
{
    int a[5]={1,2,3,4,5};
    int b[5]={1,2,3,4,5};
    int c[5],i;
    for(i=0;i<5;i++)
    {
        printf("[ A ] = %d       [ B ] = %d \n\n",a[i],b[i]);
    }
    printf("\n");
    for(i=0;i<5;i++)
    {
        c[i]=a[i]+b[i];
    }
    for (i=0;i<5;i++)
    {
        printf("Penjumlahan Array A dan B adalah = %d\n",c[i]);
    }

}
  • And then for the array of procedures, step sams eperti arrays ordinary inputkanlah syntax that the author gave.

This syntax is the same as most commands for most array calls that first declare and then create variables and add those variables then do the loop and show the loop result

#include <stdio.h>
void hitung(int c[5])
{
    int a[5]={1,2,3,4,5};
    int b[5]={1,2,3,4,5};
    int i;  
    for(i=0;i<5;i++)
    {
        c[i]= a[i]+b[i];
    }
    for(i=0;i<5;i++)
    {
        printf("\nHasilnya adalah %d",c[i]);
    }
}

The following syntax functions create the second array variable just as they are summed and then repeated again and the result is displayed variable a via printf command

void main()
{
    int a[5]={1,2,3,4,5};
    int b[5]={1,2,3,4,5};
    int c[5];
    int i;
    for(i=0;i<5;i++)
    {
        printf("Nilai dari Array A[%d] = %d\n",i,a[i]);
    }

Function syntax below to display the sum of array variables b

    printf("\n");
    for(i=0;i<5;i++)
    {
        printf("Nilai dari Array B[%d] = %d\n",i,b[i]);
    }
    hitung(c);
}
  • After writing the above syntax then the program can be executed and the results as shown below:

image.png

All syntax for the summing Array of procedures:

#include <stdio.h>
void hitung(int c[5])
{
    int a[5]={1,2,3,4,5};
    int b[5]={1,2,3,4,5};
    int i;  
    for(i=0;i<5;i++)
    {
        c[i]= a[i]+b[i];
    }
    for(i=0;i<5;i++)
    {
        printf("\nHasilnya adalah %d",c[i]);
    }
}
void main()
{
    int a[5]={1,2,3,4,5};
    int b[5]={1,2,3,4,5};
    int c[5];
    int i;
    for(i=0;i<5;i++)
    {
        printf("Nilai dari Array A[%d] = %d\n",i,a[i]);
    }
    printf("\n");
    for(i=0;i<5;i++)
    {
        printf("Nilai dari Array B[%d] = %d\n",i,b[i]);
    }
    hitung(c);
}

Thank you for visiting and hopefully useful



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Uuu yeeah, I like your post
Very useful

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • gRPC is not a proper repository for general contributions on C++. Since there is no proper one, contributions on C++ are not approved. And also tutorials about basic programming concepts like arrays, loops, variables are not approved.

The contribution doesn't follow the rules:

  • Design or video editing related tutorials, gameplay, simple on-screen instructions, ubiquitous functions (Save, Open, Print, etc.) or basic programming concepts (variables, operators, loops, etc.) will not be accepted.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 66445.86
ETH 2588.21
USDT 1.00
SBD 2.68