0% found this document useful (0 votes)
6 views

Practical Assignment 1

Uploaded by

vansh.mscit24
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)
6 views

Practical Assignment 1

Uploaded by

vansh.mscit24
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/ 11

Vansh Shah Msc.

IT 245148

Division of Two Numbers .

• Input : -

#include <stdio.h>
# include <math.h>

int main(){
float n1, n2, div;

printf("\n Enter The Value Of No.1 : ");


scanf("%f",&n1);

printf("\n Enter The Value Of No.2 : ");


scanf("%f",&n2);

div = n1/n2;

printf("\n The Division Of %f & %f : %f",n1,n2,div);


}

• Output :-

Enter The Value Of No.1 : 6

Enter The Value Of No.2 : 2

The Division Of 6.000000 & 2.000000 : 3.000000

Miles to Kilometers Conversion


Formula: K=M×1.60934

• Input :-

1
Vansh Shah Msc.IT 245148

#include <stdio.h>
#include <math.h>

int main(){
float K,M,F=1.60934;

printf("\n Enter The Total No. Of Miles : ");


scanf("%f",&M);

K=M*F;

printf("\n Your Total No. Of Kilometer's Are : %f",K);


}

• Output :-

Enter The Total No. Of Miles : 14.7

Your Total No. Of Kilometer's Are : 23.657297

Volume of a Cylinder
Formula: V=π×r^2×h

• Input :-

#include <stdio.h>
#include <math.h>

int main(){
float V,pi=3.14,r,h;

printf("\n Enter The Value Of r: ");


scanf("%f",&r);

printf("\n Enter The Value Of h: ");


scanf("%f",&h);

2
Vansh Shah Msc.IT 245148

V=pi*r*r*h;

printf("\n The Volume Of Cylinder : %f",V);


}

• Output :-

Enter The Value Of r: 5.5

Enter The Value Of h: 5.5

The Volume Of Cylinder : 522.417480

Body Mass Index (BMI) Calculation


Formula: BMI=weight/height^2

• Input :-

#include <stdio.h>
#include <math.h>

int main(){
float BMI, W, H;

printf("\n Enter The Value Of Weight : ");


scanf("%f",&W);

printf("\n Enter The Value Of Height : ");


scanf("%f",&H);

BMI = W/H*H;

printf("Body Mass Index (BMI) : %f",BMI);


}

3
Vansh Shah Msc.IT 245148

• Output :-

Enter The Value Of Weight : 60

Enter The Value Of Height : 5.2


Body Mass Index (BMI) : 60.000000

Relational Operator Check


Check if one number is not equal to another.

• Input :-

// Relational Operator Check


// Check if one number is not equal to another.
#include <stdio.h>
#include <conio.h>

int main(){
int n1,n2;

printf("\n Enter The Value Of N1 : ");


scanf("%d",&n1);

printf("\n Enter The Value Of N2 : ");


scanf("%d",&n2);

if(n1!=n2){
printf("\n %d and %d Are Not Equal", n1,n2);
}
else{
printf("\n %d and %d Are Equal", n1,n2);
}
return 0;
}

4
Vansh Shah Msc.IT 245148

• Output :-

Enter The Value Of N1 : 3

Enter The Value Of N2 : 5

3 and 5 Are Not Equal

Logical Operator Check


Check if a number is negative or less than 0.

• Input :-

//Logical Operator Check


//Check if a number is negative or less than 0.
#include <stdio.h>
#include <conio.h>

int main(){
int n1;

printf("\n Enter The Value Of N1 : ");


scanf("%d",&n1);

if(n1<0){
printf("\n The No. Is Less Than 0 Or Negative");
}
else{
printf("\n The No. Is Greater Than 0 Or Positive");
}
}

5
Vansh Shah Msc.IT 245148

• Output :-

Enter The Value Of N1 : 6

The No. Is Greater Than 0 Or Positive

Car Loan Eligibility Check


Problem: A person is eligible for a car loan if:
Age is between 22 and 60.
They have a stable income of at least 25,000 per month.
Credit score is above 650.
If the credit score is between 550 and 650, they are eligible if they can
provide collateral
(input 1 for yes).

• Input:-

#include <stdio.h>
#include <conio.h>

int main(){
int age,sal,cs;

printf("\n Enter Your Age : ");


scanf("%d",&age);

if(age>=22 && age<=60){


printf("\n Enter Your Salary Per Month : ");
scanf("%d",&sal);
if(sal>=25000){
printf("\n Enter Your Credit Score : ");
scanf("%d",&cs);
if(cs>=650 || cs>550 && cs<650){
printf("\n You Are Eligible For Car Loan");
}else{

6
Vansh Shah Msc.IT 245148

printf("\n You Are Not Eligible For Car Loan");


}
}else{
printf("\n Your Salary Is Less Than 25000 Per Month");
}
}else{
printf("\n Your Age Is Less Than 22 Or Greater Than 60");
}

• Output :-

Enter Your Age : 25

Enter Your Salary Per Month : 48000

Enter Your Credit Score : 652

You Are Eligible For Car Loan

Gym Membership Discount Eligibility Check


Problem: A person is eligible for a discount on a gym membership if:
Age is between 18 and 50.
They agree to a 1-year contract (input 1 for agreement).
They agree to a fitness assessment every 6 months.
If they are above 50 but pass the initial fitness assessment (input 1 for
passing), they are
eligible for the discount.

• Input:-

#include <stdio.h>

int main() {

7
Vansh Shah Msc.IT 245148

int age, ca, fa, iap;

printf("Enter your age: ");


scanf("%d", &age);

printf("Do you agree to a 1-year contract? (1 for Yes, 0 for No): ");
scanf("%d", &ca);

printf("Do you agree to a fitness assessment every 6 months? (1


for Yes, 0 for No): ");
scanf("%d", &fa);

if (age >= 18 && age <= 50) {


if (ca == 1 && fa == 1) {
printf("You are eligible for the gym membership
discount.\n");
} else {
printf("You are not eligible for the gym membership
discount.\n");
}
}
else if (age > 50) {
printf("You are above 50, do you pass the initial fitness
assessment? (1 for Yes, 0 for No): ");
scanf("%d", &iap);

if (iap == 1 && ca == 1 && fa == 1) {


printf("You are eligible for the gym membership
discount.\n");
} else {
printf("You are not eligible for the gym membership
discount.\n");
}
} else {
printf("You are not eligible for the gym membership
discount.\n");

8
Vansh Shah Msc.IT 245148

return 0;
}

• Output :-

Enter your age: 18


Do you agree to a 1-year contract? (1 for Yes, 0 for No): 1
Do you agree to a fitness assessment every 6 months? (1 for Yes, 0
for No): 1
You are eligible for the gym membership discount.

Print Series
Series: w, w^2, w^3, w^4,

• Input :-

#include <stdio.h>
#include <math.h>

int main() {
int w;
printf("ENTER A NUMBER : ");
scanf("%d", &w);

printf("Series: ");
for (int i = 1; i <= ; i++)
{
printf("%f", (pow(w, i)+i));
}
printf("\n");

9
Vansh Shah Msc.IT 245148

• Output:-

ENTER A NUMBER : 5
Series: 6.000000 27.000000 128.000000 629.000000 3130.000000

Print Series
Series: w^1 + 1^1, w^2 + 2^2, w^3 + 3^3,

• Input :-

#include <stdio.h>
#include <math.h>

int main() {
int w, n;

printf("Enter the value of w: ");


scanf("%d", &w);

printf("Enter the number of terms: ");


scanf("%d", &n);

printf("Series: ");
for (int i = 1; i <= n; i++) {
int term = (int)pow(w, i) + (int)pow(i, i);
printf("%d ", term);
}

printf("\n");

return 0;
}

• Output:-

Enter the value of w: 5

10
Vansh Shah Msc.IT 245148

Enter the number of terms: 5


Series: 6 29 152 881 6250

11

You might also like