0% found this document useful (0 votes)
2 views4 pages

Lab File-Format

Gzbzhajbkishjkzvhkskbhslnhjskhjsksvysljbnskshsnsjhduxhujdjdhsjsjhdjdhsysbjusksjhsnsjshsjksojjskhshxnsujnxjxjxjdngsohwnjuhxnhks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Lab File-Format

Gzbzhajbkishjkzvhkskbhslnhjskhjsksvysljbnskshsnsjhduxhujdjdhsjsjhdjdhsysbjusksjhsnsjshsjksojjskhshxnsujnxjxjxjdngsohwnjuhxnhks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Pranveer Singh Institute of Technology, Kanpur

Odd Semester 2024-25

B.Tech-First Year
Semester-I

Lab File
PROGRAMMING FOR PROBLEM SOLVING
(BCS-151)

SUBMITTED TO: SUBMITTED BY:

NAME OF FACULTY: NAME OF STUDENT:

DESIGNATION: ROLL NO/ID:

DEPARTMENT: BRANCH:
LAB PROGRAMS INDEX
Lab
OBJECTIVES DATE MARKS SIGN.
No.

i) Money’s Interest
1
ii) Roots of Quadratic Equation

i) GCD of Two Numbers


2
ii) Nth Fibonacci Term

i) Armstrong in a Range
3
ii) Check Prime

i) Checking Perfect Number


4
ii) Pascal's Triangle Printing

i) GCD of two numbers


5
ii) Reverse by Recursion

i) Linear Searching
6
ii) Binary Searching

i) Bubble sort
7
ii) Matrix Multiplication

i) Anagram Strings
8
ii) Sorting N Strings

i) Creation and Traversing Linked List


9
ii) Topper from Student Records

i) Copy the content of one file into another.


10
ii) Save the records of n employees in the file.
LAB-1
PROGRAM-1: Money’s Interest
OBJECTIVE: Interest is defined as the cost of borrowing money, as in the case of interest charged on a loan
balance. Interest can also be the rate paid for money on deposit, as in the case of a certificate of deposit. Interest
can be calculated in two ways: simple interest or compound interest. Simple interest is calculated on the
principal, or original, amount of a loan. Compound interest is calculated on the principal amount and the
accumulated interest of previous periods, and thus can be regarded as “interest on interest.”
Input Format:
A line contains three space separated values for: p, r & t.
Output Format:
Print Simple-Interest and Compound-Interest values separated by space in two decimal places
PROGRAM:
#include<stdio.h>
#include<math.h>
int main()
{
int p,t;
float r,ci,si;
scanf("%d %f %d",&p,&r,&t);
//calculate simple interest
si=(p*r*t)/100;
//calculate compound interest
ci=p*pow((1+r/100),t)-p;
printf("%.2f %.2f",si,ci);
return 0;
}
LAB-1
PROGRAM-2: Roots of Quadratic Equation
OBJECTIVE: In algebra, a quadratic equation is any equation that can be rearranged in standard form as:
ax2+bx+c=0 ,where x represents an unknown, and a, b, and c represent known numbers (coefficients).The
values of variables satisfying the given quadratic equation are called its roots. In other words, x = α is a root of
the quadratic equation f(x), if f(α) = 0. The real roots of an equation f(x) = 0 are the x-coordinates of the points
where the curve y = f(x) intersect the x-axis. b2-4ac is called as discriminant ‘d’. if d=0 roots are real and equal;
if d>0 roots are real and distinct; if d<0 roots are imaginary.

Input Format:
A line contains space separated values of three coefficients a, b, c from the equation: ax2 + bx + c = 0
Output Format:
First line will tell property of roots: "REAL AND DISTINCT" or "REAL AND EQUAL" or "IMAGINARY
ROOTS" Second line will show space separated values of both roots.

PROGRAM:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int a, b, c;
float D, r1,r2, real, imag;
scanf("%d %d %d",&a,&b,&c);
D=b*b-4.0*a*c;
if (D>0)
{
printf("REAL AND DISTINCT\n");
r1= (-b+sqrt(D))/(2*a);
r2= (-b-sqrt(D))/(2*a);
printf("%.2f %.2f",r1 , r2);
}
else if (D==0)
{
printf("REAL AND EQUAL\n");
r1 = r2 = (float)-b/(2*a);
printf("%.2f %.2f", r1, r2);
}
else
{
printf("IMAGINARY ROOTS\n");
real= (float)-b/(2*a);
imag = (float)sqrt(-D)/(2*a);
printf("%.2f+%.2f i %.2f-%.2f i", real, imag, real, imag);
}
return 0;
}

You might also like