PC Viva Q&A (SnapED Codecampus)
PC Viva Q&A (SnapED Codecampus)
VIVA Q&A
B.TECH CSE
1st SEM
SnapED
COMMUNITY
Programming In C
mindset first,
action second
"Empowering Learners, One
Click at a Time"
At SnapED codeCampus, we believe in accessible, affordable, and high-quality education for all. SnapED
will help you become industry-ready with skill-boosting courses and guides, including DSA with Java and
C++, Web Development, Python, Machine Learning, and more. Dive into expertly curated resources,
prepare smarter with important notes and questions, and achieve your academic goals seamlessly.
- Notes
- Important Questions
- Video Lectures
- Viva Ques
WhatsApp Community:
1st Community
2nd Community
”Your success
story begins here.”
Viva Ques Programming In C
General Questions
1. What is a variable in C?
A variable is a storage location in memory with a specific name and type that holds
data.
Data types specify the type of data a variable can hold, such as `int`, `float`, `char`,
etc.
4. What is recursion?
Recursion is when a function calls itself to solve smaller instances of a problem until a
base condition is met.
- If `r = 1`: `S = n × a`
5. What is the difference between a `for` loop, `do while` loop and a `while` loop?
The Fibonacci series is a sequence where each term is the sum of the previous two
terms.
- Upper Triangular Matrix: All elements below the main diagonal are zero.
- Lower Triangular Matrix: All elements above the main diagonal are zero.
A = a + b;
B = a – b;
A = a – b;
1. **How do you find the length of a string without using library functions?**
By traversing the string and counting the number of characters until the null terminator
(`\0`).
By appending the characters of the second string to the first string until the null
terminator is reached.
Swap the first character with the last, the second with the second last, and so on until
the middle of the string is reached.
It is a problem where disks are moved from one rod to another, following these rules:
Multiply the rows of the first matrix by the columns of the second matrix and sum the
products.
- `continue` skips the current iteration and moves to the next iteration.
4. What is a switch-case?
- A compiler translates the entire program into machine code before execution.
5. What are the differences between call by value and call by reference?
- Call by Reference: The actual address of the variable is passed to the function.
1. Factorial of a Number
- Q: What is a factorial?
A: The factorial of a non-negative integer \(n\) is the product of all positive integers
less than or equal to \(n\) (\(n! = n \times (n-1) \times … \times 1\)).
A: The factorial of 0 is 1.
2. Divisors of a Number
- Q: How do you find the divisors of a number?
A: A divisor of a number \(n\) is any integer \(i\) such that \(n \% I == 0\).
A: \(S = \frac{n}{2}(2a + (n-1)d)\), where \(a\) is the first term, \(d\) is the common
difference, and \(n\) is the number of terms.
- Q: What is the difference between using a formula and a loop for this?
A:The formula is more efficient, while the loop iteratively adds terms.
A: \(S = a \frac{1-r^n}{1-r}\), where \(a\) is the first term, \(r\) is the common ratio, and
\(n\) is the number of terms.
A: A `for` loop is used for a known number of iterations, while a `while` loop runs until
a condition is met.
- Q: How can you swap two numbers without using a third variable?
A: Use nested loops: outer loop for rows and inner loop for spaces and stars.
14. Tower of Hanoi
A: It involves moving \(n\) disks from the source to the destination rod, using an
auxiliary rod, following specific rules.
17.Matrix Operations
A: A matrix is upper triangular if all elements below the main diagonal are zero.
18. String Operations
- Q: How do you find the length of a string without using string functions?
A: Iterate through the array until the null character (`\0`) is reached.
A: Swap characters from the start and end, moving towards the middle.