void salinchar sasaran, char sumber - PowerPoint PPT Presentation

1 / 67
About This Presentation
Title:

void salinchar sasaran, char sumber

Description:

printf('Salinan: %sn', str2); void salin(char sasaran[ ], char sumber[ ]) { int i = 0; ... printf('Salinan: %sn', str2); void salin(char sasaran[ ], char ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 68
Provided by: irpa0402
Category:

less

Transcript and Presenter's Notes

Title: void salinchar sasaran, char sumber


1
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

_
2
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

Selamat _
3
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

Selamat _
4
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
5
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
6
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
7
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
8
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
9
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
10
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
11
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
12
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
Until
sasaran
Selamat _
13
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
14
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
15
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

sumber
sasaran
Selamat _
16
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

Selamat _
17
  • Example
  • void salin(char sasaran, char sumber)
  • int main()
  • char str18, str28
  • scanf("s", str1)
  • salin(str2, str1)
  • printf("Salinan s\n", str2)
  • void salin(char sasaran , char sumber )
  • int i 0
  • while (sumberi ! '\0')
  • sasarani sumberi
  • i
  • sasarani '\0'

Selamat Selamat _
18
Character Manipulation Function
  • Special function was provided in standard library
    C for manipulating character.
  • Refer to Jadual 12.1 (page 333) in
    Pengaturcaraan C

19
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

Input one word
20
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

Copy every character
21
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

End of string character?
22
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

Is this small alphabet?
23
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

If yes, assign capital letter for that character
into array str2
24
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

If not, assign that character into array str2
25
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

Next index
26
  • Example
  • include ltstdio.hgt
  • include ltctype.hgt
  • int main()
  • char str18, str28
  • int x 0
  • printf("Masukkan satu perkataan ")
  • scanf("s", str1)
  • while (str1x ! '\0')
  • if (islower(str1x))
  • str2x toupper(str1x)
  • else
  • str2x str1x
  • x
  • str2x '\0'
  • printf("s dalam huruf besar s\n", str1,
    str2)

Dont forget null character!!!
27
getchar() and putchar()
  • getchar() dan putchar() can be used for input and
    output character

28
  • Example
  • include ltstdio.hgt
  • define MAKS 8
  • int main()
  • char strMAKS
  • int x 0
  • do
  • strx getchar()
  • x
  • while (x lt MAKS strx-1 ! '\n')
  • strx-1 '\0'
  • x 0
  • while (strx ! '\0')
  • putchar(strx)
  • x

Read character by character into an array
29
  • Example
  • include ltstdio.hgt
  • define MAKS 8
  • int main()
  • char strMAKS
  • int x 0
  • do
  • strx getchar()
  • x
  • while (x lt MAKS strx-1 ! '\n')
  • strx-1 '\0'
  • x 0
  • while (strx ! '\0')
  • putchar(strx)
  • x

Read next character
30
  • Example
  • include ltstdio.hgt
  • define MAKS 8
  • int main()
  • char strMAKS
  • int x 0
  • do
  • strx getchar()
  • x
  • while (x lt MAKS strx-1 ! '\n')
  • strx-1 '\0'
  • x 0
  • while (strx ! '\0')
  • putchar(strx)
  • x

Loop until there are no more items in array and
before users pushing enter
31
  • Example
  • include ltstdio.hgt
  • define MAKS 8
  • int main()
  • char strMAKS
  • int x 0
  • do
  • strx getchar()
  • x
  • while (x lt MAKS strx-1 ! '\n')
  • strx-1 '\0'
  • x 0
  • while (strx ! '\0')
  • putchar(strx)
  • x

Dont forget to insert null character into an
array
32
  • Example
  • include ltstdio.hgt
  • define MAKS 8
  • int main()
  • char strMAKS
  • int x 0
  • do
  • strx getchar()
  • x
  • while (x lt MAKS strx-1 ! '\n')
  • strx-1 '\0'
  • x 0
  • while (strx ! '\0')
  • putchar(strx)
  • x

Display an output for character by character
inside an array
33
gets() and puts()
  • These functions gets() dan puts() can be used for
    input and output string

34
  • Example
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • int x, y
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • x 0
  • while (str2x ! '\0')
  • x
  • y 0
  • while (str1y ! '\0')
  • str2x str1y
  • x
  • y
  • str2x '\0'

Read two strings
35
  • Example
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • int x, y
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • x 0
  • while (str2x ! '\0')
  • x
  • y 0
  • while (str1y ! '\0')
  • str2x str1y
  • x
  • y
  • str2x '\0'

Find index for null character in str2
36
  • Example
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • int x, y
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • x 0
  • while (str2x ! '\0')
  • x
  • y 0
  • while (str1y ! '\0')
  • str2x str1y
  • x
  • y
  • str2x '\0'

Insert every character in Str1 at the end of
string in str2
37
  • Example
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • int x, y
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • x 0
  • while (str2x ! '\0')
  • x
  • y 0
  • while (str1y ! '\0')
  • str2x str1y
  • x
  • y
  • str2x '\0'

Dont forget null character
38
String manipulation functions
  • String manipulation also provided with C.
  • Such as
  • - strcpy()
  • strlen()
  • strcat()
  • strcmp()

39
strcpy()
  • strcpy() copies the contents of one string to
    another string.
  • Prototype
  • char strcpy(char sasaran, char sumber)

40
  • Example
  • include ltstdio.hgt
  • int main()
  • char asal8, salinan8
  • printf("Masukkan rentetan ")
  • gets(asal)
  • strcpy(salinan, asal)
  • printf("Salinan ")
  • puts(salinan)

_
41
  • Example
  • include ltstdio.hgt
  • int main()
  • char asal8, salinan8
  • printf("Masukkan rentetan ")
  • gets(asal)
  • strcpy(salinan, asal)
  • printf("Salinan ")
  • puts(salinan)

Masukkan rentetan _
42
  • Example
  • include ltstdio.hgt
  • int main()
  • char asal8, salinan8
  • printf("Masukkan rentetan ")
  • gets(asal)
  • strcpy(salinan, asal)
  • printf("Salinan ")
  • puts(salinan)

Masukkan rentetan kursus _
43
  • Example
  • include ltstdio.hgt
  • int main()
  • char asal8, salinan8
  • printf("Masukkan rentetan ")
  • gets(asal)
  • strcpy(salinan, asal)
  • printf("Salinan ")
  • puts(salinan)

Masukkan rentetan kursus _
44
  • Example
  • include ltstdio.hgt
  • int main()
  • char asal8, salinan8
  • printf("Masukkan rentetan ")
  • gets(asal)
  • strcpy(salinan, asal)
  • printf("Salinan ")
  • puts(salinan)

Masukkan rentetan kursus Salinan _
45
  • Example
  • include ltstdio.hgt
  • int main()
  • char asal8, salinan8
  • printf("Masukkan rentetan ")
  • gets(asal)
  • strcpy(salinan, asal)
  • printf("Salinan ")
  • puts(salinan)

Masukkan rentetan kursus Salinan kursus_
46
strlen()
  • strlen() is a function returns the length of
    string. If the string is empty, it returns zero.
  • Prototype
  • int strcpy(char rentetan)

47
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

_
48
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

Masukkan rentetan 1 bola Masukkan rentetan 2
bebola _
49
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

Masukkan rentetan 1 bola Masukkan rentetan 2
bebola _
50
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

4
6
Masukkan rentetan 1 bola Masukkan rentetan 2
bebola _
51
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

Masukkan rentetan 1 bola Masukkan rentetan 2
bebola _
52
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

Masukkan rentetan 1 bola Masukkan rentetan 2
bebola panjang rentetan 1 lt rentetan 2 _
53
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strlen(str1) gt strlen(str2))
  • printf(panjang rentetan 1 gt rentetan 2\n")
  • else if (strlen(str1) lt strlen(str2))
  • printf(panjang rentetan 1 lt rentetan 2\n")
  • else
  • printf(rentetan sama panjang\n")

Masukkan rentetan 1 bola Masukkan rentetan 2
bebola panjang rentetan 1 lt rentetan 2 _
54
strcat()
  • strcat() append first string into the end of a
    second string
  • Prototype
  • char strcat(char s1, char s2)

55
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • strcat(str2, " ")
  • strcat(str2, str1)
  • printf("Hasil selepas cantuman ")
  • puts(str2)

_
56
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • strcat(str2, "/")
  • strcat(str2, str1)
  • printf("Hasil selepas cantuman ")
  • puts(str2)

Masukkan rentetan 1 1957 Masukkan rentetan 2
31/08 _
57
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • strcat(str2, "/")
  • strcat(str2, str1)
  • printf("Hasil selepas cantuman ")
  • puts(str2)

Masukkan rentetan 1 1957 Masukkan rentetan 2
31/08 _
58
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • strcat(str2, "/")
  • strcat(str2, str1)
  • printf("Hasil selepas cantuman ")
  • puts(str2)

Masukkan rentetan 1 1957 Masukkan rentetan 2
31/08 _
59
  • include ltstdio.hgt
  • int main()
  • char str15, str211
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • strcat(str2, "/")
  • strcat(str2, str1)
  • printf("Hasil selepas cantuman ")
  • puts(str2)

Masukkan rentetan 1 1957 Masukkan rentetan 2
31/08 Hasil selepas cantuman 31/08/1957_
60
strcmp()
  • strcmp() compares two string until unequal
    characters are found or until the end of the
    string is reached.
  • Prototype
  • int strcmp(char s1, char s2)
  • Return value strcmp()
  • If s1 lt s2, so strcmp(s1, s2) lt 0
  • If s1 gt s2, so strcmp(s1, s2) gt 0
  • If s1 equal to s2, so strcmp(s1, s2) 0

61
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

_
62
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

Masukkan rentetan 1 Wira Masukkan rentetan 2
Iswara _
63
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

Masukkan rentetan 1 Wira Masukkan rentetan 2
Iswara _
64
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

Masukkan rentetan 1 Wira Masukkan rentetan 2
Iswara _
65
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

Masukkan rentetan 1 Wira Masukkan rentetan 2
Iswara _
66
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

Masukkan rentetan 1 Wira Masukkan rentetan 2
Iswara rentetan 1 gt rentetan 2 _
67
  • Example
  • include ltstdio.hgt
  • int main()
  • char str18, str28
  • printf("Masukkan rentetan 1 ")
  • gets(str1)
  • printf("Masukkan rentetan 2 ")
  • gets(str2)
  • if (strcmp(str1, str2) lt 0)
  • printf("rentetan 1 lt rentetan 2\n")
  • else if (strcmp(str1, str2) gt 0)
  • printf("rentetan 1 gt rentetan 2\n")
  • else
  • printf("rentetan 1 bersamaan rentetan 2\n")

Masukkan rentetan 1 Wira Masukkan rentetan 2
Iswara rentetan 1 gt rentetan 2 _
Write a Comment
User Comments (0)
About PowerShow.com