CSCE 150A Lab Assignment 10 - String Manipulation, Assignments of Computer Science

Information about lab assignment 10 for csce 150a - problem solving using computers course in spring 2009. The assignment involves creating a file named stringtest.c and writing the main method to perform string manipulation tasks, such as creating a string buffer, inputting a string from the user, converting all lower-case letters to upper-case using a for loop, and printing the converted string.

Typology: Assignments

Pre 2010

Uploaded on 08/31/2009

koofers-user-x30
koofers-user-x30 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009
Lab Assignment 10 - 04/02/2009
Name:
Section: 8:00 11:00 12:30 6:30
Problem 1: String Manipulation
For this problem, you will create a file stringtest.c and write the main method to perform the following
actions. (Hint: after each bullet, compile and run your program to be sure your code is correct to that point.)
Create a string buffer of size 100.
Input a string from the user using scanf
Convert all lower-case letters to upper-case by using a for loop, and doing the following at each
iteration:
1. Check if the character value is between ’A’ and ’Z’
2. If so, add (’a’-’A’) to that position (convert to lowercase).
3. Otherwise, check if the character value is between ’a’ and ’z’.
4. If so, add (’A’-’a’) to that position (convert to uppercase).
5. Characters that do not fit in these intervals can be ignored.
Print the string using printf.
Sample Input/Output (the user types any numbers following a colon)
Give me a string: Hello!
Your converted word: hELLO!

Partial preview of the text

Download CSCE 150A Lab Assignment 10 - String Manipulation and more Assignments Computer Science in PDF only on Docsity!

CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009

Lab Assignment 10 - 04/02/

Name:

Section: 8:00 11:00 12:30 6:

Problem 1: String Manipulation

For this problem, you will create a file stringtest.c and write the main method to perform the following actions. (Hint: after each bullet, compile and run your program to be sure your code is correct to that point.)

  • Create a string buffer of size 100.
  • Input a string from the user using scanf
  • Convert all lower-case letters to upper-case by using a for loop, and doing the following at each iteration: 1. Check if the character value is between ’A’ and ’Z’ 2. If so, add (’a’-’A’) to that position (convert to lowercase). 3. Otherwise, check if the character value is between ’a’ and ’z’. 4. If so, add (’A’-’a’) to that position (convert to uppercase). 5. Characters that do not fit in these intervals can be ignored.
  • Print the string using printf.

Sample Input/Output (the user types any numbers following a colon)

Give me a string: Hello! Your converted word: hELLO!