0% found this document useful (0 votes)
30 views12 pages

PSPC Lab File

Uploaded by

atharv rohilla
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)
30 views12 pages

PSPC Lab File

Uploaded by

atharv rohilla
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/ 12

PSPC LAB FILE

1. Write a C program that prints a small demo/introduction of yourself


CODE :
#include <stdio.h>

int main()

printf("My name is atharv")

printf("I am a day schollar")

printf("My course is AIML")

OUTPUT:
2. Write a C Program to calculate Simple Interest (SI) and Amount
CODE :
#include <stdio.h>

int main(){

float Pam,time, rate, Tam, Si;

printf("Give principle amount : ");


scanf ("%f", &Pam);

printf("Give time in years : ");

scanf("%f", &time);

printf("Give the rate of intrest : ");

scanf ("%f", &rate);

Si = (Pam*rate*time)/100;
Tam = Pam + Si;

printf("Total amount is : %f and Si is : %f", Tam,Si);

printf(“made by atharv”);

OUTPUT:
3. WAP to Swap Two Numbers Using Third Variable

CODE :
#include <stdio.h>

int main()

{int a,b,x;

printf("enter the value of a : ");

scanf ("%d", &a);

printf("enter the value of b : ");

scanf ("%d", &b);

x=a;
a=b;

b=x;

printf("your swapped numbers are %d and %d",a,b);

printf(“\n made by atharv”);

OUTPUT:
4. WAP to demonstrate Greatest of 3 numbers nos and to print the given
no in ascending order.
CODE:
#include <stdio.h>

int main()

{int a,b,c,x,y,z;

printf("enter the value of a : ");

scanf ("%d", &a);

printf("enter the value of b : ");

scanf ("%d", &b);

printf("enter the value of c : ");

scanf ("%d", &c);

if(a>b && a>c)

z=a;
if(b>c || b==c)

y=b;

x=c;}
else if(c>b || a==c)

y=c;

x=b;}

else if (a==b)

y=b;

x=c;}}
else if (b>a && b>c)

z=b;

if(a>c || a==c)

y=a;

x=c;}

else if(c>a || b==c)


{

y=c;

x=a;}

else if(b==a)

y=a;

x=c;}}

else if(c>a && c>b)

z=c;

if (b>a)
{

y=b;

x=a;}

else if(a>b)
{

y=a;

x=b;}

else if(c==a)
{ y=a;

x=b;}

else if(c==b)

{ y=b;

x=a;}

else if (a==b)

y=a;
x=b;}}

else if (a==b)

{z=a;

y=b;

x=c;}

printf("The numbers in ascending order are %d %d %d",x,y,z);

printf("\n made by atharv");

OUTPUT:

5. WAP to check if the number is even or odd.


CODE :
#include <stdio.h>

int main()

int Num;

printf("Enter the Number :");

scanf("%d",&Num);

if (Num%2==0)

{
printf("\n The number %d is even",Num);

else if (Num==0)

{printf("\n %d is niether Even nor Odd");}

else

{printf("\n %d is Odd",Num);}

printf("\n made by atharv");

OUTPUT:

6. WAP to perform arithmetic operations using Switch Case


statement.
CODE :
#include <stdio.h>

int main()

int a,b,c,x;

printf("enter the value of first number");

scanf("%d", &a);

printf("enter the value of second number");

scanf("%d", &b);

printf("if you want to add, press 1, subtract, press 2, divide,press3, multiply, press4");

scanf("%d",&x);

switch(x)

case 1:

c=a+b;

printf("the addition of %d and % d is %d",a,b,c);

break;

case 2:

c=a-b;

printf("the difference of %d and %d is %d",a,b,c);

break;

case 3:
c=a/b;

printf("division of %d and %d is %d",a,b,c);

break;
case 4:

c=a*b;

printf("multiplication of %d and %d is %d",a,b,c);

break;

default:

break;

printf("\n made by atharv");


}

OUTPUT :
7. WAP to calculate area of circle, rectangle, square and triangle
using Switch Case statement.
CODE :
#include <stdio.h>

int main()

int L,B,R,H,X,r;
printf("1 for circle,2 for rectangle,3 for square, 4 for triangle");

scanf("%d",&X);

switch(X)

case 1:

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

scanf("%d",&R);

r=3.14*R*R;

printf("the area of cicle is %d",R);

break;

case 2:

printf("enter the length");

scanf("%d",&L);

printf("enter the breadth");

scanf("%d",&B);
r=L*B;

printf("the area is %d",r);

break;

case 3:

printf("enter the length of one side");


scanf("%d", &L);

r=L*L;

printf("the area is %d",r);

break;

case 4:

printf("enter the length of base");

scanf("%d",&B);

printf("enter the hight");


scanf("%d",H);

r=(B*H)/2;

printf("the area is %d",r);

default:

break;

printf("\n made by atharv");

OUTPUT :

8. WAP to find factorial of a Number.


CODE :
#include <stdio.h>

int main()

int count,n,a;

printf("till which number? : ");

scanf("%d",&n);

a=1;

for(count=1;count<=n;count++)
{

a=a*count;

printf("factorial is %d",a);

printf("\n made by atharv");

OUTPUT :

You might also like