DERET KELIPATAN
#include <iostream.h>
#include <conio.h>
main()
{
int batas, i;
cout<<"Masukkan Batas dari Deret Bilangan: ";
cin>>batas;
cout<<endl;
cout<<"Deret Bilangan sampai angka "<<batas<<" adalah: "<<endl<<endl;
for(i=0;i<=batas;i+5)
{cout<<i<<" ";
i=i+5;
}
getch();
}
NESTED FOR UPRIGHT
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
void main()
{
int a, b ,c, d, bintang;
cout<<"Masukkan Jumlah Bintang: ";
cin>>bintang;
for (a=1; a<=bintang; a++)
{
for (b=bintang; b>=a; b--)
cout<<" ";
for(c=a; c<=bintang; c++)
cout<<" ";
for(d=1; d<=a; d++)
cout<<"* ";
cout<<endl;
}
getch();
}
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
int main() {
int nim[10];
char nama[10] [10];
int nilai[10];
int i, n, jum=0, maks, min;
float rata;
cout<<"oleh: Sri Lestari 3113311026\n\n\n";
cout<<"masukkan jumlah mahasiswa: ";cin>>n;
clrscr();
cout<<"oleh: Sri Lestari 3113311026\n\n\n";
maks=-1000;
min=1000;
for(i=1; i<=n; i++)
{ cout<<"masukkan nim\t: ";cin>>nim[i];
cout<<"masukkan nama\t: ";cin>>nama[i];
cout<<"masukkan nilai\t: ";cin>>nilai[i];
cout<<"\n";
jum=jum+nilai[i];
rata=jum/n;
if(nilai[i]> maks)
{ maks=nilai[i]; }
if(nilai[i]< min)
{ min=nilai[i]; }
}
clrscr();
cout<<"oleh: Sri Lestari 3113311026\n\n\n";
cout<<"jum mahasiswa : "<<n<<endl;
cout<<"\n";
cout<<"|\tnim\t|\tnama\t|\tnilai\t|\n";
for(i=1; i<=n; i++)
{
cout<<"|\t"<<nim[i]<<"\t|\t"<<nama[i]<<"\t|\t"<<nilai[i]<<"\t|"<<endl;
}
cout<<"\n";
cout<<"| jum nilai\t| \t"<<jum<<" \t|\n";
cout<<"| rata-rata\t| \t"<<rata<<" \t|\n";
cout<<"| nilai tetinggi\t| \t"<<maks<<" \t|\n";
cout<<"| nilai terendah\t| \t"<<min<<" \t|\n";
getch();
}
0 komentar:
Posting Komentar