#TUGAS PERTEMUAN KE-4
TUGAS BILANGAN PRIMA
gambar BILANGAN PRIMA
SCRIPT :
#include<stdio.h>
#include<conio.h>
#include <iostream.h>
void main()
{
int c,x,z;
z=1;c=0;
cout<<"Nama : Ilcham Nugroho"<<endl;
cout<<"NIM : TI-111035"<<endl;
cout<<"Mata Kuliah : Pemograman C++"<<endl;
cout<<"jurusan : Teknik Informatika D4 Reguler"<<endl;
cout<<"Semester : III (tiga)"<<endl<<endl;
printf("MASUKKAN JUMLAH BILANGAN = ");
scanf("%d",&x);
for(int i=1; z<=x; i++)
{
for(int j=1;j<=i;j++)
{
if(i%j==0)
{
c++;
}
}
if(c==2)
{
printf(" %d",i);
z++;
}
c=0;
}
getch();
}

No comments:
Post a Comment