/*program cari bilangan terkecil dan terbesar array*/
#include<iostream.h>
void main()
{
int x[10]={10,20,30,40,50,60,70,80,90,100};
int i;
int maks=-1000;//asumsi paling minimum
int min=1000;//asumsi paling maksimum
for(i=0;i<10;i++)
{
if(x[i]>maks)
{
maks=x[i];
}
if(x[i]<min)
{
min=x[i];
}
}
cout<<"nilai maks:"<<maks<<endl;
cout<<"nilai min:"<<min<<endl;
}
2-----------------------------------------------------------------------
#include <stdio.h>
#include <conio.h>
main( )
{
clrscr( );
putchar('U');
putchar('N');
putchar('I');
putchar('S');
putchar('L');
putchar('A');
putchar('-');
putchar('2');
putchar('0');
putchar('1');
putchar('1');
getch( );
}
3-------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
main( )
{
char nama1[10]="Dita",nama2[10]="Ani",nama3[10]="Fitri";
float a = 88.5, b = 90.8, c = 98.2;
clrscr( );
printf("%8s\t %7s\t %8s ", nama1,nama2,nama3);
printf("\n%8.2f \t %8.2f \t %8.2f ", a,b,c);
getch( );
}
Tidak ada komentar:
Posting Komentar