ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
SOURCE CODE
#include <iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int n,i;
cout<<"n Enter the number to display the multiplication table:";
cin>>n;
cout<<endl;
for(int i=0;i>=10;i++)
{
cout<<setw(5)<<n<<setw(5)<<"*"<<setw(5)<<i<<setw(5)<<n*i<<endl;
}
getch();
}
Enter the number to display the multiplication table :2
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20
SOURCE CODE
#include <iostream.h>
#include<conio.h>
class add
{
int a,b,c;
public:
void getdata();
friend void calc(add);
};
void calc(add x)
{
x.c=x.a+x.b;
cout<<"n The sum is ="<<x.c;
}
void add::getdata()
{
cout<<"n Enter a number:"<<endl;
cin>>a;
cout<<"n Enter another number :"<<endl;
cin>>b;
}
void main()
{
add y;
clrscr();
y.getdata();
calc(y);
getch();
}
Enter a number: 5
Enter another number :2
The sum is = 7_
SOURCE CODE
#include <iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<iomanip.h>
void main()
{
char a[20],b[20],ch;
clrscr();
do
{
cout<<"n Enter a word to check if its a palindrome or not :"<<endl;
gets(a);
strcpy(b,a);
strrev(b);
if(strcmp(a,b)==0)
{
cout<<"n The entered string is palindrome !!!!";
}
else
{
cout<<"n Not a palindrome !!!!!!!!!!!";
}
cout<<"n Do you wish to enter more(y/n)!!";
cin>>ch;
}while(ch=='y')
getch();
}
(3)
Enter a word to check if its a palindrome or not :
MALAYALAM
The entered string is palindrome !!!!
you wish to enter more(y/n)!! n
SOURCE CODE
#include <iostream.h>
#include<conio.h>
#include<stdlib.h>
class stack
{
int top,a[10],i,temp,n;
public:
stack()
{
top=0;
}
~stack()
{
cout<<"n DestructinG ............!!!!!!!!!!!!!!!! ";
}
void push();
void pop();
void list();
};
void stack::push()
{
if(top==10)
{
cout<<"n STACK OVERFLOW!!";
}
cout<<"n Enter the element to be pushed :n";
cin>>n;
top++;
a[top]=n;
}
void stack::pop()
{
if(top==0)
{
cout<<"n Stack overflow!!!";
}
temp=a[top];
cout<<"n The popped element is....."<<temp;
top--;
}
void stack::list()
{
cout<<"n The stack is...n";
for(i=top;i>0;i--)
{
cout<<a[i];
cout<<"n";
}
}
void main()
{
stack s;
int c;
char ch;
clrscr();
do
{
cout<<"1. PUSH :"<<endl;
cout<<"2. POP :"<<endl;
cout<<"3. LIST :"<<endl;
cout<<"4. EXIT :"<<endl;
cin>>c;
switch(c)
{
case 1:cout<<"n PUSHING ...";
s.push();
break;
case 1:cout<<"n POPING ...";
s.pop();
break;
case 1:cout<<"n LISTING ...";
s.list();
break;
case 1:cout<<"n EXIT ...";
exit(0);
break;
}
cout<<"n Do you wish to continue :";
cin>>ch;
}while(ch=='y');
getch();
}
1. PUSH :
2. POP :
3. LIST :
4. EXIT :
1
PUSHING....
Enter the element to bepushed:
3
Do you wish to continue: y
1. PUSH :
2. POP :
3. LIST :
4. EXIT :
1
PUSHING....
Enter the element to bepushed:
4
Do you wish to continue: y
1. PUSH :
2. POP :
3. LIST :
4. EXIT :
3
LISTING....
The stack is ...
4
3
Do you wish to continue: n
Ad

Recommended

????????? ??????????????
????????? ??????????????
?????? ?????????
?
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
?
Code
Code
Lay Chan Dara Raksmey
?
C++ programs
C++ programs
Mukund Gandrakota
?
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
?
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
?
11 1 ???
11 1 ???
Changwon National University
?
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
?
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
?
C & Python Introduction
C & Python Introduction
mohamedsaad24
?
Include
Include
Angie Borda
?
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
?
C++ Programming - 3rd Study
C++ Programming - 3rd Study
Chris Ohk
?
week-18x
week-18x
KITE www.kitecolleges.com
?
µþ±ô´Ç³¦°ì²õ+²µ³¦»åÈëÃÅ
µþ±ô´Ç³¦°ì²õ+²µ³¦»åÈëÃÅ
îIÒ» ºÍȪÌï
?
Circular queue
Circular queue
ShobhaHiremath8
?
Palindrome number program c
Palindrome number program c
mohdshanu
?
week-10x
week-10x
KITE www.kitecolleges.com
?
Computer programing w
Computer programing w
cexpertise
?
New microsoft word document
New microsoft word document
Abhishek Arya
?
Insertion sort
Insertion sort
Hitesh Kumar
?
1
1
swetha gokavarapu
?
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
?
cosc 281 hw2
cosc 281 hw2
Brian Goggins
?
C- Programs - Harsh
C- Programs - Harsh
Harsh Sharma
?
Add digits of number in c
Add digits of number in c
mohdshanu
?
Document
Document
AjitRaj12
?
C++ assignment
C++ assignment
Zohaib Ahmed
?
Data structure
Data structure
Markustec
?
C programs
C programs
Minu S
?

More Related Content

What's hot (20)

Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
?
C & Python Introduction
C & Python Introduction
mohamedsaad24
?
Include
Include
Angie Borda
?
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
?
C++ Programming - 3rd Study
C++ Programming - 3rd Study
Chris Ohk
?
week-18x
week-18x
KITE www.kitecolleges.com
?
µþ±ô´Ç³¦°ì²õ+²µ³¦»åÈëÃÅ
µþ±ô´Ç³¦°ì²õ+²µ³¦»åÈëÃÅ
îIÒ» ºÍȪÌï
?
Circular queue
Circular queue
ShobhaHiremath8
?
Palindrome number program c
Palindrome number program c
mohdshanu
?
week-10x
week-10x
KITE www.kitecolleges.com
?
Computer programing w
Computer programing w
cexpertise
?
New microsoft word document
New microsoft word document
Abhishek Arya
?
Insertion sort
Insertion sort
Hitesh Kumar
?
1
1
swetha gokavarapu
?
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
?
cosc 281 hw2
cosc 281 hw2
Brian Goggins
?
C- Programs - Harsh
C- Programs - Harsh
Harsh Sharma
?
Add digits of number in c
Add digits of number in c
mohdshanu
?
Document
Document
AjitRaj12
?
C++ assignment
C++ assignment
Zohaib Ahmed
?

Similar to basic programs in C++ (20)

Data structure
Data structure
Markustec
?
C programs
C programs
Minu S
?
C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
?
C++ practical
C++ practical
Rahul juneja
?
2 BytesC++ course_2014_c2_ flow of control
2 BytesC++ course_2014_c2_ flow of control
kinan keshkeh
?
Tharun prakash.pptx
Tharun prakash.pptx
TharunPrakashD
?
C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
?
9.C Programming
9.C Programming
Export Promotion Bureau
?
Cpp c++ 1
Cpp c++ 1
Sltnalt Cosmology
?
Please follow the code and comments for description As the requir.pdf
Please follow the code and comments for description As the requir.pdf
ssuserd6ce341
?
C PROGRAMS
C PROGRAMS
Malikireddy Bramhananda Reddy
?
Library functions in c++
Library functions in c++
Neeru Mittal
?
Oot practical
Oot practical
Vipin Rawat @ daya
?
Programming in C Lab
Programming in C Lab
Neil Mathew
?
Labsheet2 stud
Labsheet2 stud
rohassanie
?
This code works only for palindrome If NOT a palindrome the.pdf
This code works only for palindrome If NOT a palindrome the.pdf
adislifestyle
?
WEEK 1 -- DAY 1_20240119_220354_0000.pdf
WEEK 1 -- DAY 1_20240119_220354_0000.pdf
Rahulsahoo43
?
C faq pdf
C faq pdf
DebiPanda
?
Assignement of c++
Assignement of c++
Syed Umair
?
C++ Course - Lesson 1
C++ Course - Lesson 1
Mohamed Ahmed
?
Ad

More from Arun Nair (6)

SAP in PRECOT MERIDIAN Ltd.
SAP in PRECOT MERIDIAN Ltd.
Arun Nair
?
c++
c++
Arun Nair
?
remote method invocation
remote method invocation
Arun Nair
?
retrieving data using SQL statements
retrieving data using SQL statements
Arun Nair
?
process models- software engineering
process models- software engineering
Arun Nair
?
BITCOIN TECHNOLOGY(AAappZZ)
BITCOIN TECHNOLOGY(AAappZZ)
Arun Nair
?
SAP in PRECOT MERIDIAN Ltd.
SAP in PRECOT MERIDIAN Ltd.
Arun Nair
?
remote method invocation
remote method invocation
Arun Nair
?
retrieving data using SQL statements
retrieving data using SQL statements
Arun Nair
?
process models- software engineering
process models- software engineering
Arun Nair
?
BITCOIN TECHNOLOGY(AAappZZ)
BITCOIN TECHNOLOGY(AAappZZ)
Arun Nair
?
Ad

basic programs in C++

  • 1. SOURCE CODE #include <iostream.h> #include<conio.h> #include<iomanip.h> void main() { int n,i; cout<<"n Enter the number to display the multiplication table:"; cin>>n; cout<<endl; for(int i=0;i>=10;i++) { cout<<setw(5)<<n<<setw(5)<<"*"<<setw(5)<<i<<setw(5)<<n*i<<endl; } getch(); } Enter the number to display the multiplication table :2 2 * 1 = 2 2 * 2 = 4 2 * 3 = 6 2 * 4 = 8 2 * 5 = 10 2 * 6 = 12 2 * 7 = 14 2 * 8 = 16 2 * 9 = 18 2 * 10 = 20
  • 2. SOURCE CODE #include <iostream.h> #include<conio.h> class add { int a,b,c; public: void getdata(); friend void calc(add); }; void calc(add x) { x.c=x.a+x.b; cout<<"n The sum is ="<<x.c; } void add::getdata() { cout<<"n Enter a number:"<<endl; cin>>a; cout<<"n Enter another number :"<<endl; cin>>b; } void main() { add y; clrscr(); y.getdata(); calc(y); getch(); } Enter a number: 5 Enter another number :2 The sum is = 7_
  • 3. SOURCE CODE #include <iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<iomanip.h> void main() { char a[20],b[20],ch; clrscr(); do { cout<<"n Enter a word to check if its a palindrome or not :"<<endl; gets(a); strcpy(b,a); strrev(b); if(strcmp(a,b)==0) { cout<<"n The entered string is palindrome !!!!"; } else { cout<<"n Not a palindrome !!!!!!!!!!!"; } cout<<"n Do you wish to enter more(y/n)!!"; cin>>ch; }while(ch=='y') getch(); } (3) Enter a word to check if its a palindrome or not : MALAYALAM The entered string is palindrome !!!! you wish to enter more(y/n)!! n
  • 4. SOURCE CODE #include <iostream.h> #include<conio.h> #include<stdlib.h> class stack { int top,a[10],i,temp,n; public: stack() { top=0; } ~stack() { cout<<"n DestructinG ............!!!!!!!!!!!!!!!! "; } void push(); void pop(); void list(); }; void stack::push() { if(top==10) { cout<<"n STACK OVERFLOW!!"; } cout<<"n Enter the element to be pushed :n"; cin>>n; top++; a[top]=n; } void stack::pop() { if(top==0) { cout<<"n Stack overflow!!!"; } temp=a[top]; cout<<"n The popped element is....."<<temp; top--; } void stack::list() {
  • 5. cout<<"n The stack is...n"; for(i=top;i>0;i--) { cout<<a[i]; cout<<"n"; } } void main() { stack s; int c; char ch; clrscr(); do { cout<<"1. PUSH :"<<endl; cout<<"2. POP :"<<endl; cout<<"3. LIST :"<<endl; cout<<"4. EXIT :"<<endl; cin>>c; switch(c) { case 1:cout<<"n PUSHING ..."; s.push(); break; case 1:cout<<"n POPING ..."; s.pop(); break; case 1:cout<<"n LISTING ..."; s.list(); break; case 1:cout<<"n EXIT ..."; exit(0); break; } cout<<"n Do you wish to continue :"; cin>>ch; }while(ch=='y'); getch(); }
  • 6. 1. PUSH : 2. POP : 3. LIST : 4. EXIT : 1 PUSHING.... Enter the element to bepushed: 3 Do you wish to continue: y 1. PUSH : 2. POP : 3. LIST : 4. EXIT : 1 PUSHING.... Enter the element to bepushed: 4 Do you wish to continue: y 1. PUSH : 2. POP : 3. LIST : 4. EXIT : 3 LISTING.... The stack is ... 4 3 Do you wish to continue: n