Struktur pemrograman C
1.Header -> stdio.h.
2.Deklarasi konstanta global
3.Fungsi atau prosedur
4.Program utama
Library function pada C dan C++
>>> fungsi-fungsi yang telah tersedia oleh bahasa C++ dalam file file header
1. library stdio.h
library yang digunakan untuk operasi input output (stadio = standar ipnput dan output).
tanpa menggunakan library ini maka perintah-perintah input/output tidak dapat di eksekusi.
beberapa contoh library functions :
clearr()
fclose()
printf()
puts()
scabf()
beberapa contoh library macroes :
feof(f)
getch(f)
getchar(f)
putchar(f)
contoh 1 dalam program :
#include <stdio.h>
int main()
{
printf ("saya siswa AL BAHRI2i\n");
printf ("selamat datang di SMK Al Bahri 2");
return 0;
}
2. library math.h
library yang digunakan untuk proses peritungan secara matematis
beberapa contoh library funtions
abs()
cos()
fabs()
sin()
sqrt()
3. library stdllib.h
library ini hampir sama dengan library math.h tetapi isi dari libraty stdllib.h berbeda
beberapa functions library stdllib.h
abs()
atof()
free()
library macroes
abs(x)
random(num)
4. library string.h
library yang membrikan nilai suatu karakter string
beberapa contoh function
strcpy()
strlen
CONTOH Program
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char info[30];
strcpy (info,"Nama:nama anda");cout <<info;
cout <<"\n";
strcpy (info,"info:infoanda");cout<<info;
cout<<"\n";
return 0;
}
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char info[30];
char budi[30]
strcpy (info,"Nama:nama anda");cout <<info;
strcpy (budi,"info:info anda");cout<<info;
cout << info
cout<<"\n";
return 0;
4. library conio.h
library functionnya
clrscr()
getch()
getche()
gotoxy()
khbit()
putch()


0 Komentar