Programming Fifth Batch (String, Pseudocode Only) 45-55
Programming Fifth Batch (String, Pseudocode Only) 45-55
You may write them in python later but first only in pseudocode. You may use the built-in functions that
are given in the insert of 2022 June paper or Oct Paper.
Task # 45 : Input a string a print the following outputs one by one. Use For loop for the first 2, Repeat
Loop for the next 2 and While Loop for the last 2 patterns.
(i)
ho hous s
hou hou u
hous ho o
house h h
se ouse o
use use u
ouse se s
house e e
Task # 46 : Input a string and a character. Do not use find() method in this question.
(ii) Find the number of times the input character exists in the String.
Task # 47 : Input a Full Name and assume all characters input will be in lower case.
your resultant string must be saved in a variable first then printed to convert an upper case to
lower case you can add 32 to its ascii code and subtract 32 for vice versa
(i) A. Siddiqi
(iii) ABSAR
Task # 48 : Input a string. You may assume that user will enter either upper case or lower case but all
characters will be the same. Your program should check and convert the string into uppercase if it is in
lowercase or convert to lowercase if it is in uppercase. using their ascii code. You cannot use the built-in
function to_lower() or to_upper(). You may use other functions given in the insert like lcase() and
ucase()
Task # 49 : Input a String and a character, remove all occurrance of the character from this String. for
example
"Co**mp*u******t*er"
"*"
"Computer"
Task # 50 : Input a Credit Card Number. Your program has to check the Validity of Credit Card Number
using Luhn Method and Length check.
The check-digit is the last(16th) digit of the credit card number. This is how it works.
For example, in the card number 4578 4230 1376 9219, those digits would be:
4-5-7-8-4-2-3-0-1-3-7-6-9-2-1
8-5-14-8-8-2-6-0-2-3-14-6-18-2-2
Every time you have a two-digit number, just add those digits together for a one-digit
result:
8-5-5-8-8-2-6-0-2-3-5-6-9-2-2
8 + 5 + 5 + 8 + 8 + 2 + 6 + 0 + 2 + 3 + 5 + 6 + 9 + 2 + 2 = 71
When this number is added to the check digit, then the result must be an even multiple
of 10.
In this case:
The number is therefore valid. If the algorithm doesn't produce a multiple of 10, then
the card number cannot be valid. Write a program to validate an input Credit Card Number using the
above method given. You may use any built-in fucntion given in the insert.
Task # 51 : Input a String and print the check sum value of it. Check sum is the sum of Ascii Codes of all
charcaters. Divide the sum by 256, the remainder is the checksum.
Task # 52 : Input a HexaDecimal String. For Example "FA2B". Now convert this hex string to a denary
number.
4096 256 16 1
F A 2 B
Task # 53 : Input a string and print whether it is a palindrome or not. Palindrome are the same when
Task # 54 : Input the password from user. and check if it is valid or not. The following rules
{@,#,!,%}
Task # 55 : Input a string and a key value. The key must be between 1 to 25.
Encrypt the string and print the encrypted string. if the key is 3 then
a will be replaced by A + 3 = D
hello khoor
xyza abcd
Task # 56 : Input a range of years, and print how many years in this range have a repeated digit for
example 2012 has a repeated digit but 2013 doesn't.
The range will be input by the user. Print all the years you find to have repeated digits.