Lab07 B
Lab07 B
Sample Output:
Screen Output:
Sum of 1 2 3 4 5 6 8 9 10 23 is 71
Q-2.
Write a program that opens the file named Q2input.txt and counts the number of
characters ('a' - 'z' and 'A' - 'Z'), digits ('0'-'9'), and other characters in that file.
Print out the expected output on the screen.
Sample Input:
Q2input.txt
a s w d 1 2 3 ^ 2 * 2 d ) j # k > w ? | S I M - ! B W
Sample Output:
Screen Output:
The number of characters is 13
The number of integer numbers is 5
The number of other characters is 9
1/2
CS2311 Computer Programming 2024-25A
Q-3.
Write a program that reads a file name as a cstring (maximum of 15 characters,
including the filename extension) and counts the occurrence of letters that occur
in the file (count uppercase and lowercase versions of a letter as the same letter,
and ignore all other characters). Output the letters in alphabetical order and list
only those letters that occur in the input file. Write letters that occur in the input
file to the file named Q3output.txt.
Sample Input:
Q3input.txt
The quick brown fox jumps over the lazy dog 1234567890
Sample Output:
Screen Output:
Enter file name (maximum of 15 characters):
Q3input.txt
The occurrence of 'a' is 1
The occurrence of 'b' is 1
The occurrence of 'c' is 1
The occurrence of 'd' is 1
The occurrence of 'e' is 3
The occurrence of 'f' is 1
The occurrence of 'g' is 1
The occurrence of 'h' is 2
The occurrence of 'i' is 1
The occurrence of 'j' is 1
The occurrence of 'k' is 1
The occurrence of 'l' is 1
The occurrence of 'm' is 1
The occurrence of 'n' is 1
The occurrence of 'o' is 4
The occurrence of 'p' is 1
The occurrence of 'q' is 1
The occurrence of 'r' is 2
The occurrence of 's' is 1
The occurrence of 't' is 2
The occurrence of 'u' is 2
The occurrence of 'v' is 1
The occurrence of 'w' is 1
The occurrence of 'x' is 1
The occurrence of 'y' is 1
The occurrence of 'z' is 1
2/2