0% found this document useful (0 votes)
14 views10 pages

CP Lab Assignment

Uploaded by

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

CP Lab Assignment

Uploaded by

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

CP Lab Assignment

Name: GAURAV BHAISARE


Roll no: 23G098
Sch. No: 2311601248
Date: 12/02/2024

Q1. #include <stdio.h>


#include <math.h>
int main()
{
int principal;
int SI;
float A1;
float A2;
float A3;
float A4;
float A5;

printf("enter your principal: ");


scanf("%d" ,&principal);

SI= principal*3.5*0.1;
printf("simple interest is :%d\n", SI);
A1=(principal*(pow((1+3.5/100), 10))-principal);

printf("compound interest annually is: %f\n", A1);


A2=(principal*(pow((1+3.5/200), 20))-principal);
printf("compound interest semi annually is: %f\n", A2);
A3=(principal*(pow((1+3.5/400), 40))-principal);
printf("compound interest quarterly is: %f\n", A3);
A4=(principal*(pow((1+3.5/1200), 120))-principal);
printf("compound interest monthly is: %f\n", A4);
A5=(principal*(pow((1+3.5/36500), 3650))-principal);
printf("compound interest daily is: %f\n", A5);
return 0;
}
OUTPUT:

Q2.
#include <stdio.h>

int main(){

int a, b;
printf("Enter the value of a and b : ");
scanf("%d %d", &a ,&b);

printf("Before swapping, a = %d and b = %d\n", a, b);

int temp = a;
a = b;
b = temp;

printf("After swapping, a = %d and b = %d\n", a, b);

return 0;
}

OUTPUT:

Q3. #include<stdio.h>
int main()
{
int n,sum;
printf("Enter a 3 digit number:");
scanf("%d",&n);
sum=0;
for(;n>0;n/=10)
{
sum+=n%10;
}

printf("Sum=%d",sum);
return 0;
}

Output:

Q4.
#include<stdio.h>

int main()
{
int num;
printf("Enter a 4 digit number:");
scanf("%d",&num);

int first = num/1000;


int last= num%10;
int sum= first + last;
printf("the sum of the first and last digit is %d\n",sum);
return 0;
}

OUTPUT:
Q5.
#include<stdio.h>
int main()
{
float l,b,r;
printf("Enter Length:");
scanf("%f",&l);

printf("Enter Breadth:");
scanf("%f",&b);

printf("Enter Radius:");
scanf("%f",&r);

printf("Perimeter of Rectangle= %f \n",2*(l+b));


printf("Area of Rectangle= %f \n",(l*b));

printf("Circumference of Circle= %f \n",2*22*r/7);


printf("Area of circle= %f \n",22*r*r/7);

return 0;
} OUTPUT:

Q6.

Q7. #include<stdio.h>
int main()
{
int a,b;
printf("Enter a number a and b:");
scanf("%d %d",&a,&b);

if (a-b)
{
printf("not equal");
}
else
{
printf("equal");
}

return 0;
}

OUTPUT:
Q8. include<stdio.h>
#include<math.h>

int main() {
float a,b,r,d,x,y;
printf("enter the coordinates of center:\n");
scanf("%f",&a);
scanf("%f",&b);

printf("enter the radius of circle:\n");


scanf("%f",&r);

printf("enter the coordinates of point:\n");


scanf("%f",&x);
scanf("%f",&y);

d = sqrt(pow((x-a),2)+pow((y-b),2));

if (d==r){printf("point on the circle");}

if(d<r){printf("point lies inside the circle");}

if(d>r){printf("point lies outside the circle");}


return 0;
}
OUTPUT:

You might also like