SlideShare a Scribd company logo
SOME INTERESTING C PLUS PLUS PROGRAMS.
Q1: COUNT TOTAL OCCURRENCE OF GIVEN NUMBER FROM THE RANGE (I TO 100 (user difened))
SOLUTION 1:
#include<iostream.h>
#include<conio.h>
void main()
{
int i,count=0,n,que,rem,temp,lb,ub;
clrscr();
cout<<"Enter value of n:";
cin>>n;
cout<<"Enter lower bound (must be greater than 1) ";
cin>>lb;
cout<<"n Enter upper bound (must be less than 100) ";
cin>>ub;
if(n==0) //if the number to be searched is 0 then start search from 10 other wise it will count 01,02,..09
{
lb=10;
}
for(i=lb;i<=ub;i++)
{
que=i/10;
rem=i%10;
if((rem==n)&&(que==n))
{
count=count+2;
cout<<"n"<<i;
}
else if((rem==n)||(que==n))
{
count++;
cout<<"n"<<i;
}
}
cout<<"n => Total number of "<<n<<" Between"<<lb<<"and"<<ub<<"are :"<<count;
getch();
}
OUTPUT (QUESTION NO - 1)
Q2: WAP to print roman value of a given number.
Solution2:
#include<iostream.h>
#include<conio.h>
void calculate(int temp)
{
int a;
a=temp;
switch(a)
{
case 1:
cout<<"I";
break;
case 2:
cout<<"II";
break;
case 3:
cout<<"III";
break;
case 4:
cout<<"IV";
break;
case 5:
cout<<"V";
break;
case 6:
cout<<"VI";
break;
case 7:
cout<<"VII";
break;
case 8:
cout<<"VIII";
break;
case 9:
cout<<"IX";
break;
}
}
void main()
{
int number,n,rem,bal;
clrscr();
cout<<"enter any number:";
cin>>number;
cout<<"The Roman equivalent of "<<number<<"is:";
n=number;
rem=n%10;
bal=n-rem;
if(bal==10)
{
cout<<"X";
}
else if(bal==20)
{
cout<<"XX";
}
else if(bal==30)
{
cout<<"XXX";
}
else if(bal==40)
{
cout<<"XL";
}
else if(bal==50)
{
cout<<"L";
}
else if(bal==60)
{
cout<<"LX";
}
else if(bal==70)
{
cout<<"LXX";
}
else if(bal==80)
{
cout<<"LXXX";
}
else if(bal==90)
{
cout<<"XC";
}
else if(bal==100)
{
cout<<"C";
}
//cout<<"remainder is:"<<rem;
calculate(rem);
getch();
}
OUTPUT (QUESTION NO - 2)
Q3: Program to print the prime numbers, sum of which is a given number.
For ex: Given number is 45. It is a sum of prime numbers 2 and 43
Solution 3:
#include<iostream.h>
#include<conio.h>
int check(int temp)
{
int n =temp;
if((n==0)||(n==1)||(n==2))
return 1;
else if((n%2==0)||(n%3==0)||(n%5==0)) //if it is divisible by 2,3,5 it is not a prime number.
{
return 0;
}
else
{
return 1;
}
}
void main()
{
int a,i,bal;
clrscr();
cout<<"enter a:";
cin>>a;
for(i=0;i<a;i++)
{
bal=a-i;
// cout<<endl<<i<<"and"<<bal;
if(check(i)==1 && check(bal)==1)
{
cout<<endl<<i<<"and"<<bal;
}
}
getch();
}
OUTPUT (QUESTION NO - 3)
Q4: WAP TO COMPARE TWO MATRICES OF 2X2 ORDER.
SOLUTION 4:
#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,mat1[2][2],mat2[2][2],count=0;
clrscr();
cout<<"n ENTER THE ELEMENTS OF 1st MATRIX: n";
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++) To get the elements of 1st
matrix (00,01,10,11)
{
cout<<"Enter "<<i<<j<<"element: ";
cin>>mat1[i][j];
}
}
cout<<"n ENTER THE ELEMENTS OF 2nd MATRIX: n ";
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{ To get the elements of 2nd matrix (00,01,10,11)
cout<<"n Enter "<<i<<j<<"element: ";
cin>>mat2[i][j];
}
}
for(i=0;i<=1;i++) //for comparing each element of matrix1 and matrix2 ie a[0][0] == b[0][0]
{
for(j=0;j<=1;j++)
{
if(mat1[i][j] == mat2[i][j])
{
count++; //count will set to 4 if all the elements are same ie 00,01,10,11, it will increment each time.
}
}
}
if(count==4)
{
cout<<"MATRICES ARE EQUAL";
}
else
{
cout<<"MATRICES ARE UNEQUAL";
}
getch();
}
OUTPUT (QUESTION NO - 4)
Q5: WAP in cpp that contains 3 arrays, where the size of first two arrays is n and the size of third array is 2n. get
the values of two array from the user and show all the values of array1 and array2 in array3.
Solution:
#include<iostream.h>
#include<conio.h>
void main()
{
int a[3],b[3],c[6],i;
clrscr();
cout<<"ENTER ELEMENTS OF ARRAY 1 n";
for(i=0;i<=2;i++)
{
cout<<"enter"<<i<<"element:";
cin>>a[i];
//cin>>c[i];
}
cout<<"ENTER ELEMENTS OF ARRAY 2 n";
for(i=0;i<=2;i++)
{
cout<<"enter"<<i<<"element:";
cin>>b[i];
//cin>>c[i+3];
}
cout<<"n ELEMENTS OF ARRAY 3 are: n";
for(i=0;i<=5;i++)
{
if(i<3)
{
c[i]=a[i];
}
else
{
c[i]=b[i-3]; //when i=3, c[3]=b[3-3] ie c[3]=b[0]
}
cout<<"n element:"<<i<<"of array c is:"<<c[i];
}
getch();
}
Output( solution5)

More Related Content

What's hot

Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
ilsamaryum
 
C++ file
C++ fileC++ 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 aramseAram SE
 
VTU Network lab programs
VTU Network lab   programsVTU Network lab   programs
VTU Network lab programs
Ananda Kumar HN
 
Sortings
SortingsSortings
Sortings
maamir farooq
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
C++ 4
C++ 4C++ 4
C++ 4
Syed Umair
 
12
1212
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
AhalyaR
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
Sol7
Sol7Sol7
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? ?
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
Kandarp Tiwari
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
Abhishek Pratap
 
C questions
C questionsC questions
C questions
mohamed sikander
 
Document
DocumentDocument
Document
AjitRaj12
 

What's hot (20)

Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
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
 
VTU Network lab programs
VTU Network lab   programsVTU Network lab   programs
VTU Network lab programs
 
Sortings
SortingsSortings
Sortings
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
C programs
C programsC programs
C programs
 
C++ 4
C++ 4C++ 4
C++ 4
 
12
1212
12
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
C programs
C programsC programs
C programs
 
Sol7
Sol7Sol7
Sol7
 
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
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
 
C questions
C questionsC questions
C questions
 
Document
DocumentDocument
Document
 
programs
programsprograms
programs
 

Similar to Cpp programs

Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
Timur Safin
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
Yashpatel821746
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
kkkseld
 
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
premrings
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
shreeaadithyaacellso
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
Farhan Ab Rahman
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
Mitul Patel
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
Aroosa Rajput
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
Oops lab manual
Oops lab manualOops lab manual
Oops lab manual
Vivek Kumar Sinha
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
khaledahmed316
 

Similar to Cpp programs (20)

C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
 
Arrays
ArraysArrays
Arrays
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
 
7720
77207720
7720
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
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
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
Oops lab manual
Oops lab manualOops lab manual
Oops lab manual
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
 

More from harman kaur

Working with functions in matlab
Working with functions in matlabWorking with functions in matlab
Working with functions in matlab
harman kaur
 
Matlab 1(operations on_matrix)
Matlab 1(operations on_matrix)Matlab 1(operations on_matrix)
Matlab 1(operations on_matrix)
harman kaur
 
Creating red black tree
Creating red black treeCreating red black tree
Creating red black tree
harman kaur
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
harman kaur
 
Program to illustrate Switch, Goto and Exit statements.
Program to illustrate Switch, Goto and  Exit statements.Program to illustrate Switch, Goto and  Exit statements.
Program to illustrate Switch, Goto and Exit statements.harman kaur
 
Digital u1
Digital u1Digital u1
Digital u1
harman kaur
 
Quiz on Logic Gate
Quiz on Logic GateQuiz on Logic Gate
Quiz on Logic Gateharman kaur
 
Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)harman kaur
 
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
harman kaur
 
Msql query
Msql queryMsql query
Msql query
harman kaur
 
Rules of inference
Rules of inferenceRules of inference
Rules of inference
harman kaur
 
Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
harman kaur
 
Introduction to digital electornics
Introduction to digital electornicsIntroduction to digital electornics
Introduction to digital electornicsharman kaur
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
harman kaur
 

More from harman kaur (15)

Working with functions in matlab
Working with functions in matlabWorking with functions in matlab
Working with functions in matlab
 
Matlab 1(operations on_matrix)
Matlab 1(operations on_matrix)Matlab 1(operations on_matrix)
Matlab 1(operations on_matrix)
 
Creating red black tree
Creating red black treeCreating red black tree
Creating red black tree
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
 
Program to illustrate Switch, Goto and Exit statements.
Program to illustrate Switch, Goto and  Exit statements.Program to illustrate Switch, Goto and  Exit statements.
Program to illustrate Switch, Goto and Exit statements.
 
Digital u1
Digital u1Digital u1
Digital u1
 
Quiz on Logic Gate
Quiz on Logic GateQuiz on Logic Gate
Quiz on Logic Gate
 
Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)
 
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
 
Msql query
Msql queryMsql query
Msql query
 
Rules of inference
Rules of inferenceRules of inference
Rules of inference
 
Virtual function
Virtual functionVirtual function
Virtual function
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
 
Introduction to digital electornics
Introduction to digital electornicsIntroduction to digital electornics
Introduction to digital electornics
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 

Cpp programs

  • 1. SOME INTERESTING C PLUS PLUS PROGRAMS. Q1: COUNT TOTAL OCCURRENCE OF GIVEN NUMBER FROM THE RANGE (I TO 100 (user difened)) SOLUTION 1: #include<iostream.h> #include<conio.h> void main() { int i,count=0,n,que,rem,temp,lb,ub; clrscr(); cout<<"Enter value of n:"; cin>>n; cout<<"Enter lower bound (must be greater than 1) "; cin>>lb; cout<<"n Enter upper bound (must be less than 100) "; cin>>ub; if(n==0) //if the number to be searched is 0 then start search from 10 other wise it will count 01,02,..09 { lb=10; } for(i=lb;i<=ub;i++) { que=i/10; rem=i%10; if((rem==n)&&(que==n)) { count=count+2; cout<<"n"<<i; } else if((rem==n)||(que==n)) { count++; cout<<"n"<<i; } } cout<<"n => Total number of "<<n<<" Between"<<lb<<"and"<<ub<<"are :"<<count; getch(); } OUTPUT (QUESTION NO - 1)
  • 2.
  • 3. Q2: WAP to print roman value of a given number. Solution2: #include<iostream.h> #include<conio.h> void calculate(int temp) { int a; a=temp; switch(a) { case 1: cout<<"I"; break; case 2: cout<<"II"; break; case 3: cout<<"III"; break; case 4: cout<<"IV"; break; case 5: cout<<"V"; break; case 6: cout<<"VI"; break; case 7: cout<<"VII"; break; case 8: cout<<"VIII"; break; case 9: cout<<"IX"; break; } } void main() { int number,n,rem,bal; clrscr(); cout<<"enter any number:"; cin>>number; cout<<"The Roman equivalent of "<<number<<"is:"; n=number; rem=n%10; bal=n-rem; if(bal==10)
  • 4. { cout<<"X"; } else if(bal==20) { cout<<"XX"; } else if(bal==30) { cout<<"XXX"; } else if(bal==40) { cout<<"XL"; } else if(bal==50) { cout<<"L"; } else if(bal==60) { cout<<"LX"; } else if(bal==70) { cout<<"LXX"; } else if(bal==80) { cout<<"LXXX"; } else if(bal==90) { cout<<"XC"; } else if(bal==100) { cout<<"C"; } //cout<<"remainder is:"<<rem; calculate(rem); getch(); }
  • 5. OUTPUT (QUESTION NO - 2) Q3: Program to print the prime numbers, sum of which is a given number. For ex: Given number is 45. It is a sum of prime numbers 2 and 43 Solution 3: #include<iostream.h> #include<conio.h> int check(int temp) { int n =temp; if((n==0)||(n==1)||(n==2)) return 1; else if((n%2==0)||(n%3==0)||(n%5==0)) //if it is divisible by 2,3,5 it is not a prime number. { return 0; } else { return 1; } } void main() { int a,i,bal;
  • 6. clrscr(); cout<<"enter a:"; cin>>a; for(i=0;i<a;i++) { bal=a-i; // cout<<endl<<i<<"and"<<bal; if(check(i)==1 && check(bal)==1) { cout<<endl<<i<<"and"<<bal; } } getch(); } OUTPUT (QUESTION NO - 3) Q4: WAP TO COMPARE TWO MATRICES OF 2X2 ORDER. SOLUTION 4: #include<iostream.h> #include<conio.h> void main() { int i,j,mat1[2][2],mat2[2][2],count=0; clrscr(); cout<<"n ENTER THE ELEMENTS OF 1st MATRIX: n"; for(i=0;i<=1;i++) {
  • 7. for(j=0;j<=1;j++) To get the elements of 1st matrix (00,01,10,11) { cout<<"Enter "<<i<<j<<"element: "; cin>>mat1[i][j]; } } cout<<"n ENTER THE ELEMENTS OF 2nd MATRIX: n "; for(i=0;i<=1;i++) { for(j=0;j<=1;j++) { To get the elements of 2nd matrix (00,01,10,11) cout<<"n Enter "<<i<<j<<"element: "; cin>>mat2[i][j]; } } for(i=0;i<=1;i++) //for comparing each element of matrix1 and matrix2 ie a[0][0] == b[0][0] { for(j=0;j<=1;j++) { if(mat1[i][j] == mat2[i][j]) { count++; //count will set to 4 if all the elements are same ie 00,01,10,11, it will increment each time. } } } if(count==4) { cout<<"MATRICES ARE EQUAL"; } else { cout<<"MATRICES ARE UNEQUAL"; } getch(); } OUTPUT (QUESTION NO - 4)
  • 8. Q5: WAP in cpp that contains 3 arrays, where the size of first two arrays is n and the size of third array is 2n. get the values of two array from the user and show all the values of array1 and array2 in array3. Solution: #include<iostream.h> #include<conio.h> void main() { int a[3],b[3],c[6],i; clrscr(); cout<<"ENTER ELEMENTS OF ARRAY 1 n"; for(i=0;i<=2;i++) { cout<<"enter"<<i<<"element:"; cin>>a[i]; //cin>>c[i]; } cout<<"ENTER ELEMENTS OF ARRAY 2 n"; for(i=0;i<=2;i++)
  • 9. { cout<<"enter"<<i<<"element:"; cin>>b[i]; //cin>>c[i+3]; } cout<<"n ELEMENTS OF ARRAY 3 are: n"; for(i=0;i<=5;i++) { if(i<3) { c[i]=a[i]; } else { c[i]=b[i-3]; //when i=3, c[3]=b[3-3] ie c[3]=b[0] } cout<<"n element:"<<i<<"of array c is:"<<c[i]; } getch(); } Output( solution5)