0% found this document useful (0 votes)
3 views2 pages

Logic-Based Interview Questions Guide

The document presents a series of logic-based interview questions focused on prime and Armstrong numbers, as well as vowel identification in strings. It includes problems such as printing all prime numbers in a range, counting prime numbers, and identifying even and odd numbers using the continue statement. Each question is accompanied by sample inputs and outputs for clarity.

Uploaded by

yamuna25.telu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Logic-Based Interview Questions Guide

The document presents a series of logic-based interview questions focused on prime and Armstrong numbers, as well as vowel identification in strings. It includes problems such as printing all prime numbers in a range, counting prime numbers, and identifying even and odd numbers using the continue statement. Each question is accompanied by sample inputs and outputs for clarity.

Uploaded by

yamuna25.telu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Interview Questions – Logic-Based Programs

🔢 Prime and Armstrong Logic Questions


1. Print All Prime Numbers from m to n
Problem: Given a range from m to n, print all prime numbers in that range.
Input: m = 10, n = 30
Output: 11 13 17 19 23 29
Explanation: A prime number has only two factors: 1 and itself.

2. Count of All Prime Numbers from m to n


Problem: Count how many prime numbers are there between m and n.
Input: m = 1, n = 10
Output: 4
Explanation: Prime numbers are: 2, 3, 5, 7

3. Print All Armstrong Numbers in a Range


Problem: Print all Armstrong numbers between m and n.
Input: m = 1, n = 500
Output: 1 153 370 371 407
Explanation: Armstrong number = sum of each digit raised to the power of
number of digits.

4. First Prime Number from m to n


Problem: Find the first prime number in the given range.
Input: m = 10, n = 25
Output: 11

5. Last Prime Number from m to n


Problem: Find the last prime number in the given range.
Input: m = 10, n = 25
Output: 23

6. First Vowel in a Name


Problem: Given a string, find the first vowel in the string.
Input: name = "Krishna"
Output: i
Explanation: First vowel from left is ‘i’

7. Last Vowel in a Name


Problem: Given a string, find the last vowel in the string.
Input: name = "Ramakrishna"
Output: a
Explanation: Last vowel is ‘a’

8. Print All Even Numbers Using Continue


Problem: Use continue statement to skip odd numbers and print only even
numbers between 1 and n.
Input: n = 10
Output: 2 4 6 8 10

9. Print All Odd Numbers Using Continue


Problem: Use continue statement to skip even numbers and print only odd
numbers.
Input: n = 10
Output: 1 3 5 7 9

10. Count of Prime and Composite Numbers from m to n


Problem: Count how many are prime and how many are composite numbers
in range m to n.
Input: m = 1, n = 10
Output: Prime: 4, Composite: 4
Explanation: Prime: 2,3,5,7 | Composite: 4,6,8,9

Would you like to: - 🐍 Add code for these too? - 📥 Merge this into your main
pattern document? - ➕ Add more logic/interview questions?

You might also like