SlideShare a Scribd company logo
1 of 12
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 1
Aim:-Write a C-Program to take the radius of sphere as input and print the volume and surface
area of that sphere.
/* Program for finding volume and surface area */
#include<stdio.h>
#include<conio.h>
#define pi 3.14
int main()
{
float r,vol,area;
printf("enter the radiusn");
scanf("%f",&r);
vol= (4.0/3)*pi*r*r*r;
area=4*3.14*r*r;
printf("volume of sphere=%fnnn",vol);
printf("surface area=%f",area);
getch();
}
/* Output */
enter the radius
5
volume of sphere=523.333313
surface area=314.000000
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 2
Aim:-Write a C-Program to take a five digit number as input and calculate the sum of its digits.
/* Program to calculate the sum of five digit number*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num,a,b,c,d,total=0;
printf("enter any five digit numbern");
scanf("%d",&num);
a=num%10;
num=num/10;
b=num%10;
num=num/10;
c=num%10;
num=num/10;
d=num%10;
num =num/10;
total=num+a+b+c+d;
printf("the sum of the digit=%d",total);
getch();
}
/* Output */
enter any five digit number
15234
the sum of the digit=15
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 3
Aim:-Write a C-Program to take three side of a triangle as input and verify weather the triangle
is an isosceles, scalene or an equilateral triangle.
/* Program to Verify triangle property*/
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf("enter the value of three siden");
scanf("%d%d%d",&a,&b,&c);
if(a==b&&b!=c||b==c&&c!=a||c==a&&a!=b)
{
printf("the triangle is iso scales");
}
else if(a==b&&b==c)
{
printf("triangle is eqilatrel");
}
else
{
printf("the traingle is scalanes");
}
getch();
}
/* Output*/
enter the value of three side
2
2
5
the triangle is iso scales
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 4
Aim:-Write a C-Program that will take three positive integer as input and verify weather they
form a Phythagorean triplet or not.
/* Program to verify triangle is Phythagorean triplet or not */
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf("enter the value of siden");
scanf("%d%d%d",&a,&b,&c);
if((a*a==b*b+c*c)||(b*c==c*c+a*a)||(c*c==a*a+b*b))
printf("the traingle is phythogorean triplat");
else
printf("the traingle is not phythogorean triplat");
getch();
}
/* Output */
enter the value of side
3
4
5
the traingle is phythogorean triplet
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 5
Aim:-Write a C-Program to print all prime number between a given ranges of numbers.
/* Program to print prime numberes between given of ranges */
#include<stdio.h>
#include<conio.h>
int main()
{
int first,last,i,j;
printf("enter the first and last numbern");
scanf("%d%d",&first,&last);
for(i=first;i<=last;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
break;
}
}
if(j==i)
printf("%dt",j);
}
getch();
}
/* Output*/
enter the first and last number
100
150
101 103 107 109 113 127 131 137 139 149
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 6
Aim:-Write a C-Program to define a function that will take an integer as argument and return
the sum of digits of that integer.
/* Program to calculate the sum of digits using functions*/
#include<stdio.h>
#include<conio.h>
void sum(int x);
int main()
{
int num;
printf("enter any numbernn");
scanf("%d",&num);
sum(num);
getch();
}
void sum(int a)
{
int sum=0,b;
while(a!=0)
{
b=a%10;
a=a/10;
sum=sum+b;
}
printf("sum of digit=%d",sum);
return;
}
/* Output */
enter any number
2356
sum of digit=16
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 7
Aim:-Write a C-Program to define a recursive function that will print the reverse of its integer
argument.
* Program print the reverse number using recursive function*/
#include<stdio.h>
#include<conio.h>
void rev(int x);
int main()
{
int num;
printf("enter any numbernn");
scanf("%d",&num);
rev(num);
getch();
}
void rev(int a)
{
int b;
if(a<=0)
return;
else
printf("%d",b=a%10);
a=a/10;
rev(a);
}
/* Output */
enter any number
5687236
6327865
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 8
Aim:-Write a C-Program to print the sum of first N even number using recursive function.
/* Program to find the sum of first N numbers*/
#include<stdio.h>
#include<conio.h>
int sum(int);
int main()
{
int num,s;
printf("enter any numbern");
scanf("%d",&num);
s=sum(num);
printf("n sum of first%d even numbers is =%d",num,s);
getch();
}
int sum(int x)
{
int add;
if(x<=0)
return(0);
else
add=2*x+sum(x-1);
return(add);
}
/* Output */
enter any number
5
sum of first5 even numbers is =30
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 9
Aim:-Write a C-Program to sort an array using bubble sort technique.
*Program to sort an array using bubble sort*/
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,num,a[10],temp;
printf("enter total number to store in arrayn");
scanf("%d",&num);
printf("enter nummbersn");
for(i=0;i<num;i++)
scanf("%d",&a[i]);
for(i=0;i<num;i++)
{
for(j=0;j<num-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("stored array using bubble sortn ");
for(i=0;i<num;i++)
printf("%dt",a[i]);
getch();
}
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
/* Output */
enter total number to store in array
7
enter nummbers
12
15
6
8
3
9
5
stored array using bubble sort
3 5 6 8 9 12 15
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
Experiment No. 10
Aim:-Write a C-Program that will take the elements of two integer array of 5 element each and
insert the common element of both the array into a third array.
/*Program to find the intersection of two array values*/
#include<stdio.h>
#include<conio.h>
int main()
{
int a[5],b[5],c[5];
int i,j;
printf("nEnter the 5 values for first arrayn");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
printf("nEnter the 5 values for second arrayn");
for(i=0;i<5;i++)
scanf("%d",&b[i]);
printf("n Intersection of two array are:n");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(a[i]==b[j])
{
c[i]=a[i];
printf("%dt",c[i]);
}
}
}
getch();
}
Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.)
CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha
/* Output */
Enter the 5 values for first array
5
6
1
4
7
Enter the 5 values for second array
8
3
5
4
6
Intersections of two arrays are:
5 6 4

More Related Content

What's hot

Function recap
Function recapFunction recap
Function recap
alish sha
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
emailharmeet
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
alish sha
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
Ahmed Khateeb
 

What's hot (20)

C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
comp2
comp2comp2
comp2
 
c programing
c programingc programing
c programing
 
comp1
comp1comp1
comp1
 
Function recap
Function recapFunction recap
Function recap
 
Ternary operator
Ternary operatorTernary operator
Ternary operator
 
Lab 1
Lab 1Lab 1
Lab 1
 
Functions
FunctionsFunctions
Functions
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in c
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
 
Code optimization
Code optimization Code optimization
Code optimization
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
 
Circular queues
Circular queuesCircular queues
Circular queues
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
 
Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)
 
C Building Blocks
C Building Blocks C Building Blocks
C Building Blocks
 

Viewers also liked (9)

C
CC
C
 
Network security Lab manual
Network security Lab manual Network security Lab manual
Network security Lab manual
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
 
microprocessor 8086 lab manual !!
microprocessor 8086 lab manual !!microprocessor 8086 lab manual !!
microprocessor 8086 lab manual !!
 
Engineering practice lab manual for electronics
Engineering practice lab manual for electronicsEngineering practice lab manual for electronics
Engineering practice lab manual for electronics
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
Electrical and electronics Lab Manual
Electrical and electronics Lab ManualElectrical and electronics Lab Manual
Electrical and electronics Lab Manual
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Basic electrical lab manual
Basic electrical lab manualBasic electrical lab manual
Basic electrical lab manual
 

Similar to Pslb lab manual

Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
SANTOSH RATH
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
kushwahashivam413
 

Similar to Pslb lab manual (20)

Mech nacp lab
Mech nacp labMech nacp lab
Mech nacp lab
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
Hargun
HargunHargun
Hargun
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
C
CC
C
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
C- Programming Assignment 4 solution
C- Programming Assignment 4 solutionC- Programming Assignment 4 solution
C- Programming Assignment 4 solution
 
Systemprogramming Lab Manual
Systemprogramming Lab ManualSystemprogramming Lab Manual
Systemprogramming Lab Manual
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdfBPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
Write a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docxWrite a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docx
 
C Programming
C ProgrammingC Programming
C Programming
 

More from Vivek Kumar Sinha

More from Vivek Kumar Sinha (20)

Software engg unit 4
Software engg unit 4 Software engg unit 4
Software engg unit 4
 
Software engg unit 3
Software engg unit 3 Software engg unit 3
Software engg unit 3
 
Software engg unit 2
Software engg unit 2 Software engg unit 2
Software engg unit 2
 
Software engg unit 1
Software engg unit 1 Software engg unit 1
Software engg unit 1
 
Data structure
Data structureData structure
Data structure
 
Mathematics basics
Mathematics basicsMathematics basics
Mathematics basics
 
E commerce 5_units_notes
E commerce 5_units_notesE commerce 5_units_notes
E commerce 5_units_notes
 
B.ped
B.pedB.ped
B.ped
 
Subject distribution
Subject distributionSubject distribution
Subject distribution
 
Revision report final
Revision report finalRevision report final
Revision report final
 
Lession plan mis
Lession plan misLession plan mis
Lession plan mis
 
Lession plan dmw
Lession plan dmwLession plan dmw
Lession plan dmw
 
Faculty planning
Faculty planningFaculty planning
Faculty planning
 
Final presentation on computer network
Final presentation on computer networkFinal presentation on computer network
Final presentation on computer network
 
Np syllabus summary
Np syllabus summaryNp syllabus summary
Np syllabus summary
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Induction program 2017
Induction program 2017Induction program 2017
Induction program 2017
 
Vivek
VivekVivek
Vivek
 
E magzine et&amp;t
E magzine et&amp;tE magzine et&amp;t
E magzine et&amp;t
 
Mechanical engineering department (1)
Mechanical engineering department (1)Mechanical engineering department (1)
Mechanical engineering department (1)
 

Recently uploaded

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Recently uploaded (20)

Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Memory Interfacing of 8086 with DMA 8257
Memory Interfacing of 8086 with DMA 8257Memory Interfacing of 8086 with DMA 8257
Memory Interfacing of 8086 with DMA 8257
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 

Pslb lab manual

  • 1. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 1 Aim:-Write a C-Program to take the radius of sphere as input and print the volume and surface area of that sphere. /* Program for finding volume and surface area */ #include<stdio.h> #include<conio.h> #define pi 3.14 int main() { float r,vol,area; printf("enter the radiusn"); scanf("%f",&r); vol= (4.0/3)*pi*r*r*r; area=4*3.14*r*r; printf("volume of sphere=%fnnn",vol); printf("surface area=%f",area); getch(); } /* Output */ enter the radius 5 volume of sphere=523.333313 surface area=314.000000
  • 2. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 2 Aim:-Write a C-Program to take a five digit number as input and calculate the sum of its digits. /* Program to calculate the sum of five digit number*/ #include<stdio.h> #include<conio.h> int main() { int num,a,b,c,d,total=0; printf("enter any five digit numbern"); scanf("%d",&num); a=num%10; num=num/10; b=num%10; num=num/10; c=num%10; num=num/10; d=num%10; num =num/10; total=num+a+b+c+d; printf("the sum of the digit=%d",total); getch(); } /* Output */ enter any five digit number 15234 the sum of the digit=15
  • 3. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 3 Aim:-Write a C-Program to take three side of a triangle as input and verify weather the triangle is an isosceles, scalene or an equilateral triangle. /* Program to Verify triangle property*/ #include<stdio.h> #include<conio.h> int main() { int a,b,c; printf("enter the value of three siden"); scanf("%d%d%d",&a,&b,&c); if(a==b&&b!=c||b==c&&c!=a||c==a&&a!=b) { printf("the triangle is iso scales"); } else if(a==b&&b==c) { printf("triangle is eqilatrel"); } else { printf("the traingle is scalanes"); } getch(); } /* Output*/ enter the value of three side 2 2 5 the triangle is iso scales
  • 4. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 4 Aim:-Write a C-Program that will take three positive integer as input and verify weather they form a Phythagorean triplet or not. /* Program to verify triangle is Phythagorean triplet or not */ #include<stdio.h> #include<conio.h> int main() { int a,b,c; printf("enter the value of siden"); scanf("%d%d%d",&a,&b,&c); if((a*a==b*b+c*c)||(b*c==c*c+a*a)||(c*c==a*a+b*b)) printf("the traingle is phythogorean triplat"); else printf("the traingle is not phythogorean triplat"); getch(); } /* Output */ enter the value of side 3 4 5 the traingle is phythogorean triplet
  • 5. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 5 Aim:-Write a C-Program to print all prime number between a given ranges of numbers. /* Program to print prime numberes between given of ranges */ #include<stdio.h> #include<conio.h> int main() { int first,last,i,j; printf("enter the first and last numbern"); scanf("%d%d",&first,&last); for(i=first;i<=last;i++) { for(j=2;j<i;j++) { if(i%j==0) { break; } } if(j==i) printf("%dt",j); } getch(); } /* Output*/ enter the first and last number 100 150 101 103 107 109 113 127 131 137 139 149
  • 6. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 6 Aim:-Write a C-Program to define a function that will take an integer as argument and return the sum of digits of that integer. /* Program to calculate the sum of digits using functions*/ #include<stdio.h> #include<conio.h> void sum(int x); int main() { int num; printf("enter any numbernn"); scanf("%d",&num); sum(num); getch(); } void sum(int a) { int sum=0,b; while(a!=0) { b=a%10; a=a/10; sum=sum+b; } printf("sum of digit=%d",sum); return; } /* Output */ enter any number 2356 sum of digit=16
  • 7. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 7 Aim:-Write a C-Program to define a recursive function that will print the reverse of its integer argument. * Program print the reverse number using recursive function*/ #include<stdio.h> #include<conio.h> void rev(int x); int main() { int num; printf("enter any numbernn"); scanf("%d",&num); rev(num); getch(); } void rev(int a) { int b; if(a<=0) return; else printf("%d",b=a%10); a=a/10; rev(a); } /* Output */ enter any number 5687236 6327865
  • 8. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 8 Aim:-Write a C-Program to print the sum of first N even number using recursive function. /* Program to find the sum of first N numbers*/ #include<stdio.h> #include<conio.h> int sum(int); int main() { int num,s; printf("enter any numbern"); scanf("%d",&num); s=sum(num); printf("n sum of first%d even numbers is =%d",num,s); getch(); } int sum(int x) { int add; if(x<=0) return(0); else add=2*x+sum(x-1); return(add); } /* Output */ enter any number 5 sum of first5 even numbers is =30
  • 9. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 9 Aim:-Write a C-Program to sort an array using bubble sort technique. *Program to sort an array using bubble sort*/ #include<stdio.h> #include<conio.h> int main() { int i,j,num,a[10],temp; printf("enter total number to store in arrayn"); scanf("%d",&num); printf("enter nummbersn"); for(i=0;i<num;i++) scanf("%d",&a[i]); for(i=0;i<num;i++) { for(j=0;j<num-i;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("stored array using bubble sortn "); for(i=0;i<num;i++) printf("%dt",a[i]); getch(); }
  • 10. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha /* Output */ enter total number to store in array 7 enter nummbers 12 15 6 8 3 9 5 stored array using bubble sort 3 5 6 8 9 12 15
  • 11. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha Experiment No. 10 Aim:-Write a C-Program that will take the elements of two integer array of 5 element each and insert the common element of both the array into a third array. /*Program to find the intersection of two array values*/ #include<stdio.h> #include<conio.h> int main() { int a[5],b[5],c[5]; int i,j; printf("nEnter the 5 values for first arrayn"); for(i=0;i<5;i++) scanf("%d",&a[i]); printf("nEnter the 5 values for second arrayn"); for(i=0;i<5;i++) scanf("%d",&b[i]); printf("n Intersection of two array are:n"); for(i=0;i<5;i++) { for(j=0;j<5;j++) { if(a[i]==b[j]) { c[i]=a[i]; printf("%dt",c[i]); } } } getch(); }
  • 12. Shri Rawatpura Sarkar Institute of Technology-II New Raipur (C.G.) CSE/3rd/PSLBLab/PreparedbyVivekKumarSinha /* Output */ Enter the 5 values for first array 5 6 1 4 7 Enter the 5 values for second array 8 3 5 4 6 Intersections of two arrays are: 5 6 4