Professional Documents
Culture Documents
StudentID: 2019502075
Date:10.03.2022
Description: EED1010 Laboratory Work #2
Task 1:
#include <stdio.h>
#include <string.h>
#define SIZE 100
int main()
{
//defining arrays
char s1[SIZE];
char s2[SIZE];
if(strlen(s1)== strlen(s2)) //Checks words that their lentghs are equal each other
{
if(strspn(s1,s2)== strlen(s1)) //Checks words that their letters are same or not
puts("These two words are anagrams\n"); //displaying result
}
else {
puts("These words are not anagrams");//displaying result
}
}
Output of the programme
Task 2:
#include <stdio.h>
Task 3:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define N 20
//Hangman Game
while (error<7)
{
count = get_check(word_database[order]);
if (count>0)
{
show_letter(len,word_database[order]);
sum+= count;
if(len==sum)
{
printf("\n***************\nCongratulations!\n");
break;
}
}
if(count==0)
{
error++;
printf("\n!!!\nThe letter is not found\n");
}
}
}
else if(choice!=0 || choice !=1)
{
printf("\nThe game is not started\n");
}
if(error>=7)
{
printf("\n :( You lost!");
}
int i=0;
for(i = 0; i<N;i++)
{
CONTROL[i]=0;
}
count = 0;
error = 1;
sum = 0;
}
printf("!!!\n The game ended!\n");
return 0;
}
int line(int n) //fınction definiton
{
while(n>0)
{
printf("_");
n--;
}
printf("\n");
}
int get_check(const char word[])//function definition
{
char c;
char *p;
int i,n = strlen(word);
int k = 0;