Ege University Electrical and Electronics Engineering Introduction to Computer Programming Laboratory Lab 10 - Arrays and Strings 1) Array declaration, initialization with rule, and output. Declare an array with 100 elements. Initialize the array according to rule below: - If indice is odd (tek), initial value is eindice. - If indice is even (çift), initial value is ln(indice). Display the array, one element per line, with indice. Auxiliary functions: - math.h : double exp(double x) : returns ex. - math.h : double log(double x) : returns ln(x). 2) Word decoration. a) Accept a word as input. Capitalise the letters. Insert dot character to the beginning and ending. Insert spaces between letters. Output the final word. Auxiliary functions: - string.h : size_t strlen(const char * str) : returns character count of string str. - string.h : int toupper(int c) : returns uppercase of c. b) Modify main program you wrote, into a function. c) (HW) Modify your code (main or function) so that framed word is stored in a string. 3) Frame a word. a) Receive a word as input. Frame and output the word. For example if input was Monday, output will be: +--------+ | Monday | +--------+ Auxiliary functions: - string.h : size_t strlen(const char * str) : returns character count of string str. b) (HW) Modify main program you wrote, into a function. c) (HW) Modify your code (main or function) so that framed word is stored in a string. 4) Time array. Declare an array, which its elements store seconds, minutes, hours, day, month, and year. Ranges of values are as follows: - second : 0-59 - minute : 0-59 - hour : 0-23 - day : 0-30 - month : 1-12 - year : n<0, 0, n>0 Use define directive for indices of time units. a) Write a function for receiving a time array input from user. The function should not accept invalid values and loop until all values are valid. b) Write a function for displaying a time array on output. The output format is YYYY.MM.DD-HH:MM:SS. c) (HW) Write the functions described below. int isAearlier(int A[], int B[], int e) : returns a non-zero/true integer if A is a earlier time than B. int isAlater(int A[], int B[], int e) : returns a non-zero/true integer if A is a later time than B. void addBtoA(int A[], int B[], int e) : adds duration B to time A. void subBfrA(int A[], int B[], int e) : subtracts duration B from A. d) (HW) Do you think isAearlier, isAlater, addBtoA, subBfrA functions need the element count parameter e? Why? 5) Search letter and uppercase. a) Receive a word as input. Turn all letters of the word to lowercase, just in case. Receive a character as input. Search the character in the word. If found, turn it to uppercase. Display the final word. Auxiliary functions: - string.h : size_t strlen(const char * str) : returns character count of string str. b) Modify code you wrote for above: Receive multiple characters as input. Search for characters. Turn found characters to uppercase. 6) Words to sentence. a) Recieve a string as input. Display the string on output. b) After you wrote code for previous bullet, run the program and enter a string of multiple words. Examine the output. c) Write a program that continuously receives words as input until last entered word is a dot. Combine entered words into a sentence. Display the sentence. Auxiliary functions: - string.h : int strcmp(const char * str1, const char * str2) : returns zero/false if str1 and str2 are same. - string.h : char * strcat(char * destination, const char * source) : appends string source to string destination. d) (HW) Modify the code you wrote for previous bullet, so that input operation stops, also if space reserved for sentence cannot accommodate new words anymore. 7) (HW) a) Receive a word as input. Receive an unsigned integer that is smaller than length the word. Loop until integer input is valid. Remove the letter at indice that is the entered unsigned integer. Display the word. b) Modify main program you wrote for previous bullet into a function. 8) (HW) Remove vowels from a word. Receive a word as input. Erase vowel (sesli) letters from the word, except first one. Display the final word. For example, if input is deniz, output is denz. If input is okyanus, output is okyns. Auxiliary functions: - string.h : size_t strlen(const char * str) : returns character count of string str.
© Copyright 2026 Paperzz