Pps Question
Pps Question
Pps Question
Question 1: An employee can apply for loan at the begginning of every six months but he will be
sanctioned the amount as per rules:
Rule 1: an employee cannot enjoy more than two loans at any point of time
Rule 2: maximum permissible total loan is limited and depends upon the category of the employee.
write a c program to process the loan applications of the employees and sanction the loan.
#define MAX_LOANS 2
int main() {
// Prompt the user to enter their employee ID, category, and desired loan amount
scanf("%d", &employee_id);
scanf("%d", &category);
printf("Enter the loan amount you would like to apply for: ");
scanf("%d", &loan_amount);
if (loan_amount <= 0) {
return 0;
printf("Loan amount exceeds the maximum permissible amount for executives. Please try again.\
n");
return 0;
printf("Loan amount exceeds the maximum permissible amount for managers. Please try again.\n");
return 0;
printf("Loan amount exceeds the maximum permissible amount for staff. Please try again.\n");
return 0;
// Add code here to read the employee's loan history from a database or file
printf("You already have the maximum number of loans. Please pay off one of your existing loans
before applying for another.\n");
return 0;
// Calculate and display the loan amount that the user is eligible for
printf("Loan application approved for employee ID %d. You are eligible for a loan amount of Rs. ",
employee_id);
switch (category) {
case 1:
printf("%d\n", EXECUTIVE_LIMIT);
break;
case 2:
printf("%d\n", MANAGER_LIMIT);
break;
case 3:
printf("%d\n", STAFF_LIMIT);
break;
default:
printf("0\n");
// Add code here to update the loan database or file with the new loan information
return 0;
}
Question2: Using pointer write a function that receives the character string and a
character as an argument and deletes all occurences of that character in a string.
The function should return the corrected string with no holes.
// Loop through the string and copy only the characters that are not equal to the given
character
if (*src != c) {
*dest = *src;
dest++;
src++;
*dest = '\0'; // Add null terminator at the end of the new string
int main() {
char str[100], c;
printf("Enter a string: ");
scanf("%c", &c);
delete_char(str, c);
return 0;
In the delete_char() function, two pointer variables are declared: src and dest. The
src pointer points to the beginning of the string, and the dest pointer points to the
beginning of the new string. In the while loop, the function checks each character of the
string. If the character is not equal to the given character c, it is copied to the new string
using the dest pointer. If the character is equal to c, it is skipped. After the loop, the
dest pointer points to the end of the new string, so a null terminator is added to mark
the end of the string.
In the main() function, the user is prompted to enter a string and a character to delete.
The delete_char() function is called with the string and character as arguments, and
the corrected string is printed. Note that the fgets() function is used to read the string
input because it is safer than using scanf() for input strings.
Question3 :write a program in c to calculate the bill amount for an item given its quantity
sold,value,discount and tax.
#include <stdio.h>
int main() {
int quantity;
scanf("%d", &quantity);
scanf("%f", &value);
scanf("%f", &discount);
scanf("%f", &tax);
// Apply discount
// Apply tax
return 0;
In this program, the user is prompted to enter the quantity sold, value per item,
discount percentage, and tax percentage. These values are stored in variables quantity,
value, discount, and tax.
The program calculates the total amount before discount by multiplying the quantity
sold by the value per item. It then applies the discount by subtracting the discount
percentage from the total amount. Finally, it applies the tax by adding the tax
percentage to the discounted amount.
The resulting bill amount is stored in the amount variable and is printed to the console
using printf() with a precision of two decimal places using the format specifier %.2f.
Note that this program assumes that the discount and tax percentages are entered as
floating-point values between 0 and 100. If you want to calculate the discount and tax
amounts directly from the values entered by the user, you can divide them by 100
before applying them in the calculations.
Question 4:write a c program to check whether a given number is even or odd number or
not.
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
if (num % 2 == 0) {
printf("%d is an even number.\n", num);
} else {
return 0;
#include <stdio.h>
#include <math.h>
int main() {
scanf("%f", &principal);
scanf("%f", &rate);
scanf("%f", &time);
return 0;
#include <stdio.h>
int main() {
int matrix[5][5];
int i, j;
if (j <= i) {
matrix[i][j] = 1;
} else if (j > i + (4 - i) / 2) {
matrix[i][j] = -1;
} else {
matrix[i][j] = 0;
printf("\n");
return 0;
Question 7: Define a structure data type called time_struct containing three members
integer hour,integer minute and integer second.Develop a program in c that would assign
values to the individual members and display the time in the following format :
15 : 45 : 40
#include <stdio.h>
struct time_struct {
int hour;
int minute;
int second;
};
int main() {
time.hour = 15;
time.minute = 45;
time.second = 40;
return 0;
Question 9:Define a structure data type named date containing three integer members
day,month and year.Develop an interactive modular program to perform the following
tasks
iii)to print the data in format april 28, 2020 by a 3rd function.
#include <stdio.h>
struct date {
int day;
int month;
int year;
};
// function to read data into structure members
scanf("%d", &d->day);
scanf("%d", &d->month);
scanf("%d", &d->year);
return 0;
return 0;
if (d.month == 2 && d.day == 29 && (d.year % 4 != 0 || (d.year % 100 == 0 && d.year % 400 != 0))) {
return 0;
return 1;
}
// function to print the data in format "April 28, 2020"
char *months[] = {"", "January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"};
int main() {
struct date d;
read_date(&d);
if (validate_date(d)) {
print_date(d);
} else {
printf("Invalid date.\n");
return 0;
Question 10: DEFINE THE TERM DEBUGGING EXPLAIN ANY TWO DEBUGGING TECHNIQUES.
Debugging is the process of finding and fixing errors (or bugs) in a computer program.
It is an essential part of software development and involves identifying and correcting
issues that prevent the program from functioning as intended.
The types of errors and the debugging techniques vary depending on the stage of development and the
environment.
To understand different types of debugging, we need to understand the different types of errors. Errors
are usually of three types:
Build and compile-time errors
Runtime errors
Logic errors
Build and compile-time errors happen at the development stage when the code is being built. These
errors are thrown by the compiler or the interpreter while building the source code. In other words,
build or compile-time errors prevent the application from even starting. These errors often result from
syntax errors, like missing semicolons at the end of a statement or class not found. These errors are easy
to spot and rectify because most IDE or compilers find them for you. The compiler or the interpreter will
tell you the exact piece of code that is causing the problem.
Runtime errors occur and can be identified only while running the application. They occur only when the
source code doesn’t have any compiler or syntax error, and the compiler or the interpreter cannot
identify the runtime error during the build stage. Mostly, runtime errors depend on the user input or the
environment. These kinds of errors can be identified by using try-catch blocks in your program and
logging the error message properly.
Logic errors occur after the program is successfully compiled and running and it gives you an output. A
logic error is when the result of the program is incorrect. These errors can not be caught using the try-
catch blocks. Logic errors are also called semantic errors, and they occur due to some incorrect logic
used by the developer to solve a problem while building the application.
1. Print debugging: This technique involves inserting print statements into the code to
display the values of variables or other information at specific points in the program's
execution. This can help identify where the program is going wrong and provide clues as
to what might be causing the issue.
For example, suppose a program is supposed to calculate the sum of two numbers, but
the result is incorrect. By adding print statements to display the values of the variables
used in the calculation, the programmer can see whether the values are what they
should be. If not, they can use the output to track down the problem.
2. Debugging tools: There are many software tools available to assist with debugging,
including integrated development environments (IDEs) that provide a debugger. A
debugger allows the programmer to step through the code one line at a time, examine
the values of variables at each step, and even modify the values to see how the program
reacts.
Debugging tools can also provide other helpful features, such as the ability to set
breakpoints, which pause the program's execution at a specific point, and watchpoints,
which trigger a pause when a specific variable is accessed or modified.
By using debugging techniques like these, programmers can quickly identify and fix
errors in their code, resulting in more reliable and functional software.