Assignment: Fundamentals of Programming in C++
Total Marks: 64 (8 x 8)
Instructions:
1. Answer all the questions.
2. Code should be properly formatted and commented.
3. Submit a well-documented report along with program outputs.
Questions:
Q1. Introduction to C++ (8 Marks)
Explain the key differences between C and C++ with examples. Write a simple C++ program to print
"Hello, C++ World!" and explain each part of the program.
Q2. Variables, Data Types, and Operators (8 Marks)
Write a C++ program that takes two numbers as input and performs the following operations using
arithmetic and relational operators: addition, subtraction, multiplication, division, modulus,
comparison, and logical AND/OR. Display the results.
Q3. Conditional Statements (If-Else) (8 Marks)
Write a C++ program to check whether a given number is even or odd using if-else. Extend the
program to check whether the number is positive, negative, or zero.
Q4. Loops (8 Marks)
Write a C++ program to print the Fibonacci series up to n terms using both for loop and while loop.
Compare their efficiency in terms of execution.
Q5. Functions (8 Marks)
Write a C++ program to calculate the factorial of a number using:
a) Iterative function
b) Recursive function
Q6. Pointers and Dynamic Memory Allocation (8 Marks)
Write a C++ program to dynamically allocate memory for an array of n integers using new and delete.
Take n and array elements as input from the user, calculate the sum of the elements, and display it.
Q7. Arrays and Strings (8 Marks)
Write a C++ program to take a string input from the user and count the number of vowels and
consonants in the string. Also, convert the string to uppercase without using built-in functions.
Q8. Arrays and Searching (8 Marks)
Write a C++ program to implement binary search on a sorted array. The program should take n
elements as input, sort them, and then search for a given number using the binary search algorithm.