1
0
UAHCode/CPE325/L1_Problem2/problem2.c

33 lines
1.2 KiB
C
Raw Normal View History

2022-08-28 21:12:16 +00:00
/*------------------------------------------------------------------------------
* File: problem2.c
* Function: Change lowercase letters to uppercase letters
* Description: This C program changes the message <EFBFBD>Welcome to CPE 325 in Fall 2021!<EFBFBD> to
* "WELCOME TO CPE 325 IN FALL 2021!"
* Input: None
* Output: "WELCOME TO CPE 325 IN FALL 2021!"
* Author(s): Noah Woodlee
* Lab Section: 09
* Date: Aug 20, 2021
*----------------------------------------------------------------------------*/
#include <msp430.h>
#include <stdio.h>
#include <ctype.h>
int main(){
int i;
char msg[] ="Welcome to CPE 325 in Fall 2021!";
size_t size = sizeof(msg)/sizeof(msg[0]); // size of msg[]
for (i=0; i < size;i++){ // loop over the array
char str = msg[i]; // store the character in msg[i] as a char in str
int str_as_int=(int)str; // covert string to an integer
// check if str is lower-case
if (islower(str)){
msg[i]=str_as_int-32; // if it is, subtract 32 from the character value
}
else msg[i]=str_as_int; //else keep the string the same
}
printf("%s\n",msg); // print output
}