CSE110
Offline 1: Conditional Statement
Problem 1: Caesar Cipher
Problem Statement:
Write a C program that allows the user to choose between encryption and decryption of a
single alphabet character using the Caesar Cipher technique. The Caesar Cipher shifts
each letter of the alphabet by a fixed number of positions.
The program should:
1. Ask the user whether they want to encrypt or decrypt (using a choice input: 1 for
encrypt, 2 for decrypt).
2. Ask for a single alphabet character.
3. Ask for an integer key (shift).
4. Based on the selected option, perform Caesar Cipher encryption or decryption.
5. Print the final result.
Rules:
● The cipher should only apply to alphabetic characters (a–z or A–Z).
● For encryption, shift the character forward in the alphabet by the key.
● For decryption, shift the character backward by the key.
● If shifting goes beyond z or before a, it should wrap around.
● If the character is non-alphabetic, print a message Invalid Character.
Input:
● An integer choice (1 for encryption, 2 for decryption)
● A single character
● An integer shift key
Output:
● The resulting character after encryption or decryption
Example 1 (Encryption):
Input:
1
H
3
Output:
Example 2 (Decryption):
Input:
2
d
3
Output:
a
Problem 2: Cyclic Swap of Three Variables
Problem Statement:
Write a C program to swap the values of three variables in a cyclic order. After the swap:
● a should take the value of b
● b should take the value of c
● c should take the value of a (original value)
The program should:
● Ask the user to input three integer values.
● Perform the cyclic swap using a temporary variable.
● Print the new values of the variables after swapping.
Rules:
● Input values should be integers.
● Output the updated values of a, b, and c after the swap.
Input:
● Three integer values: a, b, and c
Output:
● The values of a, b, and c after the cyclic swap
Example 1:
Input:
10 20 30
Output:
20 30 10
Example 2:
Input:
5 15 25
Output:
15 25 5
N.B.: Strictly adhere to the input and output format specified above. Do not include any extra
printf statements, debug outputs, or additional text in your output. Ensure your program
reads the input exactly as described and produces the output in the exact format, with no
additional newlines or characters.
Submission Guidelines:
1. Create a folder using your roll number. Example: 2406xyz
2. Create a file named 1.c and solve problem 1 there.
3. Create another file named 2.c and solve problem 2 there.
4. Now, remove unnecessary files. The 2406xyz should contain only 1.c and 2.c files.
5. Zip it using name 2406xyz.zip
6. Submit it in the moodle.
7. Wrong submission format will result in 0 mark in this assignment.
Please do not copy from any sources (friends, internet, AI tools like ChatGPT,
etc.). Doing so will result in a -100% penalty.