CSE Assignment For MID
CSE Assignment For MID
Interpreted Language:
1. Advantages:
Ease of Development: Interpreted languages often have simpler and more flexible
syntax, making them easier to learn and write code in.
Portability: Since the code is executed by an interpreter, it is generally more portable
across different platforms without the need for recompilation.
Dynamic Typing: Dynamic typing allows for more flexible variable types, making it
easier to write code quickly.
2. Disadvantages:
Performance: Interpreted languages are generally slower than compiled languages
because code is executed line by line by the interpreter.
Deployment Complexity: Distributing an interpreted language application may require
distributing the interpreter as well, which can complicate deployment.
Code Security: Code in interpreted languages may be easier to reverse-engineer, which
can be a security concern.
Compiled Language:
1. Advantages:
Performance: Compiled languages typically offer faster execution because the
code is compiled into machine code optimized for the target platform.
Optimization: Compilers can perform various optimizations, such as dead code
elimination and inclining, to produce highly efficient code.
Static Typing: Strong static typing can catch type-related errors at compile time,
reducing runtime errors.
Code Security: Compiled code is harder to reverse-engineer, providing better
code security.
2. Disadvantages:
Compilation Overhead: The compilation process can be time-consuming,
especially for large projects, which can slow down development.
Platform Dependency: Compiled code is specific to a target platform, so
portability may be a concern.
Steeper Learning Curve: Compiled languages often have stricter syntax and
typing rules, which can make them more challenging for beginners.
Factors to Consider:
Project Requirements: Consider the specific needs of your project. If you need high
performance, a compiled language may be a better choice. For rapid prototyping and
scripting tasks, an interpreted language might be more suitable.
Development Team: Evaluate the expertise and familiarity of your development team
with the chosen language. A team with experience in a particular language will be more
productive.
Execution Speed: If your project requires real-time or high-performance execution, a
compiled language is typically a better choice.
Deployment and Distribution: Consider how you will deploy your application.
Interpreted languages may require users to have the interpreter installed, while compiled
languages produce standalone executables.
Security Concerns: Evaluate the security requirements of your project. Compiled code
can be harder to reverse-engineer, which may be important for sensitive applications.
Development Time: Consider your project's timeline. Interpreted languages often allow
for faster development, which can be advantageous for rapid iterations.
The syntax for an entry control loop in C is typically exemplified by the While loop:
while (condition) {
// Loop body
Exit Control Loop: An exit control loop is a type of loop where the loop body is executed at
least once, and the loop condition is checked after the loop body has been executed. Even if the
condition is initially false, the loop body will execute at least once before the loop exits.
The syntax for an exit control loop in C is typically exemplified by the do-while loop:
do {
// Loop body
} while (condition);
Condition: This is the loop control condition. It is a Boolean expression that is evaluated
after each iteration. The loop body is executed at least once before the condition is
checked.
Similarities:
1. Both entry control loops and exit control loops are used for repetitive execution of a
block of code based on a certain condition.
2. They both have a loop control condition that determines whether the loop should
continue executing or terminate.
3. Both types of loops can be used to solve various repetitive tasks in programming.
Dissimilarities:
1. Execution Order:
Entry Control: In an entry control loop (while), the loop condition is checked before entering
the loop body. If the condition is false initially, the loop body is skipped entirely.
Exit Control: In an exit control loop (do-while), the loop body is executed at least once, and
then the loop condition is checked. This ensures that the loop body always executes at least once.
2. Syntax:
Entry Control: The while loop has the condition placed before the loop body.
Exit Control: The do-while loop has the condition placed after the loop body.
3. Use Cases:
Entry Control: Use when you want to execute the loop body zero or more times based
on a condition.
Exit Control: Use when you want to ensure that the loop body is executed at least once,
even if the condition is initially false.
Section 2 .
Answer to the question no – (b)
Here is a C program that calculates the average of the best (n-1) credit theory (CT) marks out of
n CTs:
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 0) {
if (n == 1) {
int ctMark;
scanf("%d", &ctMark);
int ctMarks[n];
scanf("%d", &ctMarks[i]);
int sum = 0;
sum += ctMarks[i];
This program first takes the value of n, the number of CTs. It then checks if n is less than or
equal to 0 or equal to 1 and handles these cases separately. For n greater than 1, it reads the CT
marks into an array, sorts them in descending order, calculates the sum of the best (n-1) CT
marks, and finally, calculates and displays the average of the best (n-1) CT marks.
#include <stdio.h>
#include <stdbool.h>
void printPrimes(int n) {
if (isPrime[p] == true) {
isPrime[i] = false;
if (isPrime[i]) {
printf("\n");
int main() {
int n;
scanf("%d", &n);
if (n < 2) {
} else {
printPrimes(n);
}
return 0;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int fib[n];
fib[0] = 0;
fib[1] = 1;
}
printf("Fibonacci sequence of the first %d numbers:\n", n);
printf("\n");
return 0;
#include <stdio.h>
int main() {
int year;
scanf("%d", &year);
} else {
return 0;
}
Section 3:
Answer to the question no- (a)
#include <stdio.h>
int main() {
int n, i, j, space;
scanf("%d", &n);
space = n;
// Print spaces
printf(" ");
printf("*");
printf("\n");
space--;
return 0;
}
Answer to the question no _ (c)
To create an inverted pyramid of stars in C, you can modify the code as follows:
#include <stdio.h>
int main() {
int n, i, j;
scanf("%d", &n);
// Print stars
printf("* ");
printf("\n");
return 0;
}
Section 4
Answer to the question no _ (b)
1234
x=4
Answer to the question no _ (d)
x=1