Menggunakan Array, Function, Struct
ARRAY
#include<iostream.h>
void main()
{
int a[3]={7},l;
l=a[0]*a[0];
cout<<"Sisi = "<<a[0]<<endl;
cout<<"Hasil persegi =" <<l;
}
FUNGTION
#include<iostream.h>
void persegi(int a);
void main()
{
int a,l;
a=7;
persegi(a);
}
void persegi (int a)
{
int l;
l=a*a;
cout<<"Sisi = "<<a<<endl;
cout<<"Hasil persegi =" <<l;
}
STRUCT
#include<iostream.h>
void main()
{
struct P
{ int a;
int l;
};
P O;
O.a=7;
O.l=O.a*O.a;
cout<<"Sisi = "<<O.a<<endl;
cout<<"Hasil persegi =" <<O.l;
}
No comments:
Post a Comment