Lab Practice April 25 - 27

  • Program 1:
  • Program 2:

  • Program 3
    Write a function int sumASCII(char s[]) that finds the sum of the ASCII values of the elements of the array s. Write a C program that reads a string (use function stringInput that we wrote in class) and finds the sum of the ASCII values of the elements using function sumASCII. Define the size of array using #define statement.
  • Program 4
    Write a program that declares one character array that can hold 20 elements (including '\0'). Define thesize of array using #define statement. The program prints the input string in the following way: each character will be printed the amount of time that corresponds to the index value. The first character will be not printed at all. For example, if the input was
    program
    The output will be
    roogggrrrraaaaammmmmm
    Write a function void funPrint(char s[]) that will perform this strange printing and use this function in your program. The string input should be done by function as well.

  • Program 5
    Write a function int Palindrome (char s[ ]) that returns 1 if s is a palindrome (palindrome is a word, phrase, verse, or sentence that reads the same backward or forward) and 0 otherwise. Examples of palindromes:
    I PREFER PI
    Never odd or even,
    No lemons, no melon.
    Write a program that reads a string (use function stringInput that we wrote in class) and checks if the input string is palindrome or not. Define the size of array using #define statement.
  • Problem 6: Write a function changeString that has two parameters: two character arrays: old_array and new_array. The function changes the original array in the following way: each digit is replaced by the character '*', all chars that are not letters and digits are omitted, and the rest of the chars remain the same Write a program that reads original string, make changes and prints string after changes are made. For example:
    Input: Yana123*((!
    Output: Yana***

  • Problem 7: Write a function int findATG that has one parameter array of chars. The function will look for sub-string ATG inside the original string and returns the index of the first occurence of ATG in the original string or -1 if ATG is not in the string Write a program to test your function