C Unit 1 Assignment
C Unit 1 Assignment
Assignment-1
Programme: BCA Semester: I Paper Code: BCA 101T Academic Year: 2024-25
.
General Instructions
1. Dry run your code first in order to analyse the code behavior, implement it on the system
and then write it.
2. Identify errors in the code that prevent it from producing the correct output or cause it to
fail. Try to identify the cause of error.
3. Correct the errors if any observed while executing the code.
4. Test your corrected code to ensure it works as expected.
5. Submit your corrected code along with comments
Question 1: Write a C program that accepts two integers from the user and performs all basic
arithmetic operations (addition, subtraction, multiplication, and division). Additionally,
increment one of the integers using both prefix and postfix unary operators.
Question 2 : Write a C program that takes a user’s age as input and determines if the person is
eligible to vote. Display “Eligible to vote” if the age is 18 or more; otherwise, display “Not
eligible to vote.”
Question 3: Write a C program that reads a number from 1 to 7 and prints the corresponding
day of the week using a switch statement. Use 1 for Monday, 2 for Tuesday, and so on.
Question 4: Write a C program to calculate the factorial of a number using a for loop. The
number should be taken as input from the user.
Question 5: Write a C program that prompts the user to guess a number between 1 and 100.
The program should continue asking the user to guess the number using a do-while loop until
the correct number is entered.
Question 6: Write a C program that uses the goto statement to jump out of a for loop when a
certain condition is met. The program should print numbers from 1 to 10 but skip the number
5 using goto.
Question 7: Write a C program that accepts three numbers from the user and determines if
they form a valid triangle. For a triangle to be valid, the sum of any two sides must be greater
than the third side.
INSTITUTE OF INFORMATION TECHNOLOGY & MANAGEMENT
Accredited ‘A’ Grade by NAAC &Recognised U/s 2(f) of UGC act
Rated Category `A+’ by SFRC & `A’ by JAC Govt. of NCT of Delhi
Approved by AICTE & Affiliated to GGS Indraprastha University, New Delhi
Question 8: Predict the output for the following code with explanation:
#include <stdio.h>
int main() {
int a = 5, b = 10, c = 15;
int result;
return 0;
}