string1
Write a C program called string1.c that reads in a string of no more than 80 characters and then prints it back out (within double quotes).
Your string? C programming is fun You entered: "C programming is fun"
Main Contents Page | CTEC1401 Programming in C |
Quick Reference |
Week 14: Consolidation | Week 15: Strings |
Week 16: Functions I |
Before the lab session read CFTTP Chapters 9 and 10.
Write a C program called string1.c that reads in a string of no more than 80 characters and then prints it back out (within double quotes).
Your string? C programming is fun You entered: "C programming is fun"
Write a C program called string2.c that reads in a string of no more than 80 characters and then prints it back out (within double quotes) with all spaces replaced by stars.
Your string? C programming is fun Modified to: "C*programming*is*fun"
Write a C program called string3.c that reads in a string of no more than 80 characters and then prints it back out (within double quotes) with all lower case characters changed to upper case.
Your string? C programming is fun Modified to: "C PROGRAMMING IS FUN"
Write a C program called string4.c that reads in a string of no more than 80 characters and a number. The string should be modified by applying the Caeser cipher to every lower case character in the string. The number is used to control the encryption (i.e. the amount of character rotation). Once encrypted the string should be printed out.
Your string? Hello! I like C Rotation ? 1 Modified to: "Hfmmp! I mjlf C"
Write a C program called string5.c that reads in a string of no more than 80 characters and prints it out backwards.
Your string? Hello! I like C Modified to: "C ekil I !olleH"
Write a C program morse.c that gets an input string of text characters from the user and generates a new string containing the message in Morse code.
A "dot" is represented by the character 'o' and a dash by
three hyphen characters '---
'. The space between the parts of a
single letter is represented by a single space ' ';
the space between letters is represented by
three space characters ' '; the space between words is
represented by seven space characters
' '.
For example, the string "I like C
" would become:
o o o --- o o o o --- o --- o --- o --- o
The program should also output the overall length of the generated Morse code message (i.e. the length of the encoded string). In the example the length of the encoded string is 59.
Write a C program charcount.c that
a: 3 b: 0 c: 0 d: 2 e: 2 f: 1 g: 0 h: 0 i: 3 j: 0 k: 0 l: 0 m: 2 n: 3 o: 2 p: 0 q: 0 r: 1 s: 0 t: 3 u: 0 v: 0 w: 1 x: 0 y: 0 z: 0
Hint: This program is a bit trickier than the others so here is
an outline of the processing required
char
array to store the stringint
array of size 26 to store the count
for each letter e.g. count[0] is the number of a's, count[1] the
number of b's etc.
Write a C program getwords.c that gets an input string of text characters from the user and prints out all the separate words in the text.
A word is defined as a sequence of characters terminated by punctuation or whitespace. For example, the input
Into the valley of death rode the six hundred.would produce the output:
Into the valley of death rode the six hundred