SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Presented By- Harsh Sharma
OUTPUT
Enter value of a: 45
Enter value of b: 56
Original value of a is:45
Original value of b is:56
After Swapping
New value of a is:56
New value of b is:45
Output
Value of a is: 10
Value of b is: 15
After swapping
New Value of a is: 15
New value of b is: 10
OUTPUT
Enter value of a: 45
Enter value of b: 56
Original value of a is:45
Original value of b is:56
After Swapping
New value of a is:56
New value of b is:45
 #include<iostream.h>
 #include<conio.h>
 class swapping
 {
 public:
 int anew,bnew;
 void swap( int anew, int bnew);
 };
 void swapping :: swap(int anew , int bnew)
 {
 anew= anew+bnew;
 bnew=anew-bnew;
 anew=anew-bnew;
 cout<<"new value of a is:"<<anew<<endl;
 cout<<"new value of b is:"<<bnew<<endl;
 }
 void main()
 {
 int a,b;
 clrscr();
 swapping s1,s2;
 cout<<"Enter value of a:";
 cin>>a;
 cout<<"Enter value of b:";
 cin>>b;
 cout<<“Value of a is:"<<a<<endl;
 cout<<“Value of b is:"<<b<<endl;
 s1.swap(a,b);
 getch();
 }
OUTPUT
Enter value of a: 25
Enter value of b: 65
Value of a is: 25
Value of b is:65
After swapping
Value of a is: 65
Value of b is: 25
 #include<iostream.h>
 #include<conio.h>
 void main()
 {
 int a[10],i,j,m,loc=0;
 clrscr();
 cout<<"enter 10 elements of array:";
 for(i=0;i<=9;i++)
 {
 cin>>a[i];
 }
 m=a[0];
 for(j=1;j<=9;j++)
 {
 if(a[j]>m)
 {
 m=a[j];
 loc=j+1;
 }
 }
 cout<<"max value is:"<<m;
 cout<<"its loc is:"<<loc;
 getch();
 }
OUTPUT
Enter 10 elements of array:
5
8
2
12
65
36
98
45
25
96
Max value is: 98
Its location is: 7
 #include<iostream.h>
 #include<conio.h>
 class greatest
 {
 public:
 int a[10],j,max;
 int largest() //member func of greatest class that returns a value of integer type
 {
 cout<<"enter 10 elements of array:";
 for(int i=0;i<=9;i++)
 {
 cin>>a[i];
 }
 max=a[0];
 for(j=1;j<=9;j++)
 {
 if(a[j]>max)
 {
 max=a[j];
 }
 }
 return max;
 }
 };
 void main()
 {
 int max1;
 clrscr();
 greatest g1;
 max1=g1.largest();
 cout<<"Greatest of ten values is:"<<max1;
 getch();
 }
OUTPUT
Enter 10 elements of array:
5
8
2
12
65
36
98
45
25
96
Max value is: 98
 #include<iostream.h>
 #include<conio.h>
 void main()
 {
 int min,a[10],I;
 clrscr();
 cout<<“Enter 10 elements of array.”;
 for(i=0;i<=9;i++)
 cin>>a[i];
 for(j=1;j<=9;j++)
 {
 If(a[j]<min)
 min=a[j];
 }
 cout<<“smallest of 10 values is:”<<min;
 getch();
 }
OUTPUT
Enter 10 elements of array:
5
8
2
12
65
36
98
45
25
96
Smallest of ten values is: 2
 #include<iostream.h>
 #include<conio.h>
 class smallest
 {
 public:
 int a[10],j,min;
 int calculate_smallest()
 {
 cout<<"enter 10 elements of array:";
 for(int i=0;i<=9;i++)
 {
 cin>>a[i];
 }
 min=a[0]; //0th element is set as minimum values
 for(j=1;j<=9;j++)
 {
 if(a[j]<min)
 {
 min=a[j];
 }
 }
 return min;
 }
 };
 void main()
 {
 int min1;
 clrscr();
 smallest s1;
 min1=s1.calculate_smallest();
 cout<<“Smallest of ten values is:"<<min1;
 getch();
 }
OUTPUT
Enter 10 elements of array:
-5
8
2
12
65
36
98
45
25
96
Smallest of ten values is: -
5
 #include<iostream.h>
 #include<conio.h>
 void main()
 {
 int a , b, c;
 clrscr();
 cout<<“Enter value of a:”;
 cin>>a;
 cout<<“ Enter value of b:”;
 cin>>b;
 c=a>b?a:b; //using conditional operator, c stores the
biggest of two values.
 cout<<a<<“ is greatest”;
 getch();
 }
OUTPUT
Enter value of a: 56
Enter value of b: 36
56 is greatest.
 #include<iostream.h>
 #include<conio.h>
 class comparison
 {
 public:
 int a1,b1,max;
 int greatest (int a1,int b1)
 {
 max=a1>b1?a1:b1; //using conditional(ternary operator) to compare a and b, storing result in
max.
 return max;
 }
 };
 void main()
 {
 int a, b;
 clrscr();
 cout<<"enter a:";
 cin>>a;
 cout<<"enter b:";
 cin>>b;
 comparison c1;
 cout<<"Greatest of two values is:"<<c1.greatest(a,b);
 getch();
 }
OUTPUT
Enter value of a: 62
Enter value of b: 36
Greatest of two values is:62
 #include<iostream.h>
 #include<conio.h>
 void main()
 {
 int a , b, c, max;
 clrscr();
 cout<<"Enter value of a:";
 cin>>a;
 cout<<" Enter value of b:";
 cin>>b;
 cout<<"Enter value of c:";
 cin>>c;
 max=a<b?(a<c?a:c):(b<c?b:c); //using conditional operator,
max stores the biggest of three values.
 cout<<max<<" is smallest";
 getch();
 }
OUTPUT
Enter value of a: 96
Enter value of b: 125
Enter value of c: 36
36 is greatest

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Project_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_endsProject_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_ends
 
C questions
C questionsC questions
C questions
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Implementing string
Implementing stringImplementing string
Implementing string
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
C++ practical
C++ practicalC++ practical
C++ practical
 
1
11
1
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
C++ file
C++ fileC++ file
C++ file
 
1 borland c++ 5.02 by aramse
1   borland c++ 5.02 by aramse1   borland c++ 5.02 by aramse
1 borland c++ 5.02 by aramse
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
Code
CodeCode
Code
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 

Andere mochten auch

3Com 6000M-RCTL
3Com 6000M-RCTL3Com 6000M-RCTL
3Com 6000M-RCTLsavomir
 
Presentacion dioscar ley de victima
Presentacion dioscar ley de victimaPresentacion dioscar ley de victima
Presentacion dioscar ley de victimadioscar ramones
 
AQUAFAN Introduction - Watco Group
AQUAFAN Introduction - Watco GroupAQUAFAN Introduction - Watco Group
AQUAFAN Introduction - Watco GroupBertus Bolknak
 
Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...
Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...
Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...Muhammad Hazim Shamsul Zamri
 
3Com 1698-110-000-6.02
3Com 1698-110-000-6.023Com 1698-110-000-6.02
3Com 1698-110-000-6.02savomir
 
3Com 3C96100D-AMGT
3Com 3C96100D-AMGT3Com 3C96100D-AMGT
3Com 3C96100D-AMGTsavomir
 
หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)
หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)
หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)G ''Pamiiz Porpam
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh SharmaHarsh Sharma
 
Gem 7-20-green dream
Gem 7-20-green dreamGem 7-20-green dream
Gem 7-20-green dreamijcparish
 
CMO Disrupt Sydney 2016
CMO Disrupt Sydney 2016CMO Disrupt Sydney 2016
CMO Disrupt Sydney 2016Grant Stewart
 

Andere mochten auch (18)

3Com 6000M-RCTL
3Com 6000M-RCTL3Com 6000M-RCTL
3Com 6000M-RCTL
 
Videojuego
VideojuegoVideojuego
Videojuego
 
Evaluación de desempeño directivo UGEL Y DRE
Evaluación de desempeño directivo UGEL Y DREEvaluación de desempeño directivo UGEL Y DRE
Evaluación de desempeño directivo UGEL Y DRE
 
Presentacion dioscar ley de victima
Presentacion dioscar ley de victimaPresentacion dioscar ley de victima
Presentacion dioscar ley de victima
 
AQUAFAN Introduction - Watco Group
AQUAFAN Introduction - Watco GroupAQUAFAN Introduction - Watco Group
AQUAFAN Introduction - Watco Group
 
Ozone layer
Ozone layer Ozone layer
Ozone layer
 
Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...
Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...
Tugasan 4 amalan terbaik dala pembangun bandar mapan a155649 muhammad hazim b...
 
Equipo#2 domingo trabajo_grupal _pdf
Equipo#2 domingo trabajo_grupal _pdfEquipo#2 domingo trabajo_grupal _pdf
Equipo#2 domingo trabajo_grupal _pdf
 
3Com 1698-110-000-6.02
3Com 1698-110-000-6.023Com 1698-110-000-6.02
3Com 1698-110-000-6.02
 
3Com 3C96100D-AMGT
3Com 3C96100D-AMGT3Com 3C96100D-AMGT
3Com 3C96100D-AMGT
 
Arquitectura islamica unidad v
Arquitectura islamica unidad vArquitectura islamica unidad v
Arquitectura islamica unidad v
 
Marine Industry
Marine IndustryMarine Industry
Marine Industry
 
หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)
หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)
หลักสูตรสอนภาษาไทยในฐานะภาษาต่างประเทศ (ในต่างประเทศ)
 
Trait Theory
Trait TheoryTrait Theory
Trait Theory
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh Sharma
 
Hispania
HispaniaHispania
Hispania
 
Gem 7-20-green dream
Gem 7-20-green dreamGem 7-20-green dream
Gem 7-20-green dream
 
CMO Disrupt Sydney 2016
CMO Disrupt Sydney 2016CMO Disrupt Sydney 2016
CMO Disrupt Sydney 2016
 

Ähnlich wie C- Programs - Harsh

Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programsharman kaur
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual finalAhalyaR
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++ Arun Nair
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++Pranav Ghildiyal
 
constructors and destructors in c++
constructors and destructors in c++constructors and destructors in c++
constructors and destructors in c++HalaiHansaika
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - ReferenceMohammed Sikander
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 

Ähnlich wie C- Programs - Harsh (20)

Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
C++ file
C++ fileC++ file
C++ file
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
Oop1
Oop1Oop1
Oop1
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
 
7720
77207720
7720
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++
 
Lecture05
Lecture05Lecture05
Lecture05
 
constructors and destructors in c++
constructors and destructors in c++constructors and destructors in c++
constructors and destructors in c++
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
cpp promo ppt.pptx
cpp promo ppt.pptxcpp promo ppt.pptx
cpp promo ppt.pptx
 
Pointers
PointersPointers
Pointers
 
P1
P1P1
P1
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 

Kürzlich hochgeladen

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 

Kürzlich hochgeladen (20)

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 

C- Programs - Harsh

  • 2.
  • 3. OUTPUT Enter value of a: 45 Enter value of b: 56 Original value of a is:45 Original value of b is:56 After Swapping New value of a is:56 New value of b is:45
  • 4. Output Value of a is: 10 Value of b is: 15 After swapping New Value of a is: 15 New value of b is: 10
  • 5. OUTPUT Enter value of a: 45 Enter value of b: 56 Original value of a is:45 Original value of b is:56 After Swapping New value of a is:56 New value of b is:45
  • 6.  #include<iostream.h>  #include<conio.h>  class swapping  {  public:  int anew,bnew;  void swap( int anew, int bnew);  };  void swapping :: swap(int anew , int bnew)  {  anew= anew+bnew;  bnew=anew-bnew;  anew=anew-bnew;  cout<<"new value of a is:"<<anew<<endl;  cout<<"new value of b is:"<<bnew<<endl;  }  void main()  {  int a,b;  clrscr();  swapping s1,s2;  cout<<"Enter value of a:";  cin>>a;  cout<<"Enter value of b:";  cin>>b;  cout<<“Value of a is:"<<a<<endl;  cout<<“Value of b is:"<<b<<endl;  s1.swap(a,b);  getch();  } OUTPUT Enter value of a: 25 Enter value of b: 65 Value of a is: 25 Value of b is:65 After swapping Value of a is: 65 Value of b is: 25
  • 7.  #include<iostream.h>  #include<conio.h>  void main()  {  int a[10],i,j,m,loc=0;  clrscr();  cout<<"enter 10 elements of array:";  for(i=0;i<=9;i++)  {  cin>>a[i];  }  m=a[0];  for(j=1;j<=9;j++)  {  if(a[j]>m)  {  m=a[j];  loc=j+1;  }  }  cout<<"max value is:"<<m;  cout<<"its loc is:"<<loc;  getch();  } OUTPUT Enter 10 elements of array: 5 8 2 12 65 36 98 45 25 96 Max value is: 98 Its location is: 7
  • 8.  #include<iostream.h>  #include<conio.h>  class greatest  {  public:  int a[10],j,max;  int largest() //member func of greatest class that returns a value of integer type  {  cout<<"enter 10 elements of array:";  for(int i=0;i<=9;i++)  {  cin>>a[i];  }  max=a[0];  for(j=1;j<=9;j++)  {  if(a[j]>max)  {  max=a[j];  }  }  return max;  }  };  void main()  {  int max1;  clrscr();  greatest g1;  max1=g1.largest();  cout<<"Greatest of ten values is:"<<max1;  getch();  } OUTPUT Enter 10 elements of array: 5 8 2 12 65 36 98 45 25 96 Max value is: 98
  • 9.  #include<iostream.h>  #include<conio.h>  void main()  {  int min,a[10],I;  clrscr();  cout<<“Enter 10 elements of array.”;  for(i=0;i<=9;i++)  cin>>a[i];  for(j=1;j<=9;j++)  {  If(a[j]<min)  min=a[j];  }  cout<<“smallest of 10 values is:”<<min;  getch();  } OUTPUT Enter 10 elements of array: 5 8 2 12 65 36 98 45 25 96 Smallest of ten values is: 2
  • 10.  #include<iostream.h>  #include<conio.h>  class smallest  {  public:  int a[10],j,min;  int calculate_smallest()  {  cout<<"enter 10 elements of array:";  for(int i=0;i<=9;i++)  {  cin>>a[i];  }  min=a[0]; //0th element is set as minimum values  for(j=1;j<=9;j++)  {  if(a[j]<min)  {  min=a[j];  }  }  return min;  }  };  void main()  {  int min1;  clrscr();  smallest s1;  min1=s1.calculate_smallest();  cout<<“Smallest of ten values is:"<<min1;  getch();  } OUTPUT Enter 10 elements of array: -5 8 2 12 65 36 98 45 25 96 Smallest of ten values is: - 5
  • 11.  #include<iostream.h>  #include<conio.h>  void main()  {  int a , b, c;  clrscr();  cout<<“Enter value of a:”;  cin>>a;  cout<<“ Enter value of b:”;  cin>>b;  c=a>b?a:b; //using conditional operator, c stores the biggest of two values.  cout<<a<<“ is greatest”;  getch();  } OUTPUT Enter value of a: 56 Enter value of b: 36 56 is greatest.
  • 12.  #include<iostream.h>  #include<conio.h>  class comparison  {  public:  int a1,b1,max;  int greatest (int a1,int b1)  {  max=a1>b1?a1:b1; //using conditional(ternary operator) to compare a and b, storing result in max.  return max;  }  };  void main()  {  int a, b;  clrscr();  cout<<"enter a:";  cin>>a;  cout<<"enter b:";  cin>>b;  comparison c1;  cout<<"Greatest of two values is:"<<c1.greatest(a,b);  getch();  } OUTPUT Enter value of a: 62 Enter value of b: 36 Greatest of two values is:62
  • 13.  #include<iostream.h>  #include<conio.h>  void main()  {  int a , b, c, max;  clrscr();  cout<<"Enter value of a:";  cin>>a;  cout<<" Enter value of b:";  cin>>b;  cout<<"Enter value of c:";  cin>>c;  max=a<b?(a<c?a:c):(b<c?b:c); //using conditional operator, max stores the biggest of three values.  cout<<max<<" is smallest";  getch();  } OUTPUT Enter value of a: 96 Enter value of b: 125 Enter value of c: 36 36 is greatest

Hinweis der Redaktion

  1. This is a program to swap two values using the third variable(temp). It does not use the class concept. The next program is same but it is done using class concept.
  2. This is same program as the previous one, but it use class structre.
  3. It is a program to swap two values without using third variable and without using class structure