0% found this document useful (0 votes)
30 views

Assignment Questions - Functions PDF

The document provides 5 sample questions to test C++ functions of varying difficulties: 1) Print squares of first 5 natural numbers. 2) Print area and circumference of a circle given its radius. 3) Check if a person is eligible to vote given their age. 4) Print odd numbers between two given numbers. 5) Print prime numbers between two given numbers.

Uploaded by

Shourya Bhardwaj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Assignment Questions - Functions PDF

The document provides 5 sample questions to test C++ functions of varying difficulties: 1) Print squares of first 5 natural numbers. 2) Print area and circumference of a circle given its radius. 3) Check if a person is eligible to vote given their age. 4) Print odd numbers between two given numbers. 5) Print prime numbers between two given numbers.

Uploaded by

Shourya Bhardwaj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Functions

Assignment Questions
Assignment Questions

Q1 - Write a function to print squares of the first 5 natural numbers. (Easy)

Sample Output: 1 4 9 16 25

Q2 - Given radius of a circle. Write a function to print the area and circumference of the circle. (Easy)
Sample Input: r=3
Sample Output: Area : 28.26
Circumference : 18.84

Q3 - Given the age of a person, write a function to check if the person is eligible to vote or not. (Easy)
Sample Input: 19
Sample Output: Yes
Sample Input: 17
Sample Output: No

Q4 - Given two numbers a and b, write a program using functions to print all the odd numbers (Medium)
between them.
Sample Input: 1 10
Sample Output: 1 3 5 7 9

Q5 - Given two numbers a and b, write a program to print all the prime numbers present between (Hard)
a and b.
Sample Input: 2 10
Sample Output: 2 3 5 7

Cracking the Coding Interview in C++ - Foundation

You might also like