contoh program struct,c++
contoh program C ++ Stuck #include <stdio.h>
#include <stdlib.h>
#define NUM
struct PESERTA
{
int idsekolah;
int momor_perseta;
};
void x(struct PESERTA p[],int n )
{
int i;
for(i=1;i<=n;i++)
printf("No.%d idsekolah:%d momor_perseta:%d nilai:%f\n",i,p[i].idsekolah,p[i].momor_perseta);
}
main(void)
{
int i,num,n;
struct PESERTA *p;
printf("banyaknya data:");scanf("%d",&num);
p=(PESERTA*)malloc(n*sizeof(PESERTA));
for(i=1;i<=num;i++)
{
printf("No.%d\n",i);
printf("\t id sekolah:");scanf("%d",&p[i].idsekolah);
printf("\t momor_perseta:");scanf("%d",&p[i].momor_perseta);
}
x(p,num);
}
#include <stdlib.h>
#define NUM
struct PESERTA
{
int idsekolah;
int momor_perseta;
};
void x(struct PESERTA p[],int n )
{
int i;
for(i=1;i<=n;i++)
printf("No.%d idsekolah:%d momor_perseta:%d nilai:%f\n",i,p[i].idsekolah,p[i].momor_perseta);
}
main(void)
{
int i,num,n;
struct PESERTA *p;
printf("banyaknya data:");scanf("%d",&num);
p=(PESERTA*)malloc(n*sizeof(PESERTA));
for(i=1;i<=num;i++)
{
printf("No.%d\n",i);
printf("\t id sekolah:");scanf("%d",&p[i].idsekolah);
printf("\t momor_perseta:");scanf("%d",&p[i].momor_perseta);
}
x(p,num);
}
0 komentar:
Post a Comment