15. Write a program to find sum of n elements entered by the user. To write this program, allocate memory dynamically using malloc() / calloc() functions or new operator.
Tuesday, December 15, 2020
13. Write a program in which a function is passed address of two variables and then alter its contents.
13. Write a program in which a function is passed address of two variables and then alter its contents.
14. Write a program which takes the radius of a circle as input from the user, passes it to another function that computes the area and the circumference of the circle and displays the value of area and circumference from the main() function.
14. Write a program which takes the radius of a circle as input from the user, passes it to another function that computes the area and the circumference of the circle and displays the value of area and circumference from the main() function.
11. WAP that prints a table indicating the number of occurrences of each alphabet in the text entered as command line arguments.
11. WAP that prints a table indicating the number of occurrences of each alphabet in the text entered as command line arguments.
how to execute from command line
c++ code :
12. Write a program that swaps two numbers using pointers.
12. Write a program that swaps two numbers using pointers.
10. WAP to perform following actions on an array entered by the user: i.Print the even-valued elements ii.Print the odd-valued elements iii.Calculate and print the sum and average of the elements of array iv.Print the maximum and minimum element of array v.Remove the duplicates from the array vi.Print the array in reverse order The program should present a menu to the user and ask for one of the options. The menu should also include options to re-enter array and to quit the program.
10. WAP to perform following actions on an array entered by the user:
i.Print the even-valued elements
ii.Print the odd-valued elements
iii.Calculate and print the sum and average of the elements of array
iv.Print the maximum and minimum element of array
v.Remove the duplicates from the array
vi.Print the array in reverse order
The program should present a menu to the user and ask for one of the options. The menu should also include options to re-enter array and to quit the program.
Sunday, December 6, 2020
CMS-A-CC-5-11-P: Relational Database Management System
CMS-A-CC-5-11-P: Relational Database Management System
Core Course- 11, Practical, Credit:02, Contact hours: 40 hours.
RDBMS Lab using My SQL & PHP
11WAP to calculate factorial and to compute the factors of a given no. (i)using recursion, (ii) using iteration
11. WAP to calculate factorial and to compute the factors of a given no. (i)using recursion, (ii) using iteration
#include<iostream>
using namespace std;
class cl
{
private:
int no,fl;
public:
void input()
{
fl=1;
cout<<"\nEnter the no: ";
cin>>no;
}
void factorial()
{
if(no==0)
{
cout<<"\n"<<no<<"!= "<<1;
}
else
{
for(int i=no;i>=1;i--)
{
fl=fl*i;
}
cout<<"\n"<<no<<"!= "<<fl;
}
}
int factorial(int n)
{
if(n > 1)
return n * factorial(n - 1);
else
return 1;
}
void factor()
{
cout<<"\nFactors of "<<no<<"= ";
if(no==1)
{
cout<<1;
}
for(int i=2;i<=no;i++)
{
if(no % i ==0)
{
cout<<" "<<i;
}
}
}
void factor(int n,int i)
{
if(n==1)
cout<<"1";
else
{
if(i <= n)
{
if(n%i == 0)
{
cout << i << " ";
}
factor(n,i+1);
}
}
}
};
int main()
{
cl ob;
int ch,n,x;
do
{
cout<<"\n1.FACTORIAL using Iteration \n2.FACTORIAL using Recursion \n3.Compute FACTORS using Iteration \n4.Compute FACTORS using Recursion \n5.Exit";
cout<<"\nEnter ur Choice: ";
cin>>ch;
switch(ch)
{
case 1:
ob.input();
ob.factorial();
break;
case 2:
cout<<"\nEnter the no: ";
cin>>n;
x=ob.factorial(n);
cout<<"\n"<<n<<"!= "<<x;
break;
case 3:
ob.input();
ob.factor();
break;
case 4:
cout<<"\nEnter the no: ";
cin>>n;
cout<<"\nFactors of "<<n<<"= ";
ob.factor(n,2);
break;
case 5:
cout<<"\nEXIT";
break;
default:
cout<<"\nSorry! Invalid Choice";
}
}
while(ch!=5);
return 0;
}
10
CMSACOR05P: Data Structures Lab
10. WAP to scan a polynomial using linked list and add two polynomial.
PROGRAME : WAP to scan a
polynomial using linked list and add two polynomial…
PROGRAME CODE
#include<stdio.h>
#include<iostream>
using namespace std;
class node{
public:
int
degree;
int
data;
node*
link1;
node(){
degree=0;
data=0;
link1=NULL;
}
};
class poly{
public:
node*
head;
poly(){
head=NULL;
}
int
check(int k){
node*
ptr=head;
while(ptr!=NULL){
if(ptr->degree==k)
return
1;
ptr=ptr->link1;
}
return
0;
}
void
append(node* n){
if(head==NULL)
head=n;
else{
if(check(n->degree))
cout<<"THE
DGREE IS ALREADY EXIST TRY WITH ANOTHER ....."<<endl;
else{
node*
ptr=head;
while(ptr!=NULL){
if(ptr->link1==NULL){
ptr->link1=n;
break;
}
ptr=ptr->link1;
}
}
}
}
poly
operator +(poly ob1){
node*
ptr=head;
node*
ptr1=head;
node*
ptr3=NULL;
node*
ptr4=head;
node*
ptr5=head;
node*
ptr6=head;
cout<<"ADDITION
SUCCESSFULL "<<endl;
while(ptr1->link1!=NULL)
ptr1=ptr1->link1;
ptr1->link1=ob1.head;
for(ptr=head;ptr!=NULL;ptr=ptr->link1){
ptr3=ptr->link1;
while(ptr3!=NULL){
if(ptr3->degree==ptr->degree){
ptr->data=ptr->data+ptr3->data;
}
ptr3=ptr3->link1;
}
}
while(ptr4!=NULL){
ptr6=ptr4;
ptr5=ptr4->link1;
while(ptr5!=NULL){
if(ptr4->degree==ptr5->degree)
ptr6->link1=ptr5->link1;
ptr6=ptr5;
ptr5=ptr5->link1;
}
ptr4=ptr4->link1;
}
}
void
display(){
if(head==NULL)
cout<<".........EMPTY............"<<endl;
else{
node*
ptr=head;
while(ptr!=NULL){
cout<<"("<<ptr->data<<"
x^"<<ptr->degree<<")";
if(ptr->link1!=NULL)
cout<<"
+ ";
ptr=ptr->link1;
}
cout<<"=
0 ";
}
}
};
int main(){
int
opt=0;
poly
ob;
poly
ob1;
do{
cout<<"\nPRESS
0 TO EXIT...."<<endl;
cout<<"PRESS
1 TO APPEND NODE FOR 1st POLYNOMIAL..........."<<endl;
cout<<"PRESS
2 TO APPEND NODE FOR 2nd POLYNOMIAL..........."<<endl;
cout<<"PRESS
3 TO DISPLAY 1st POLYNOMIAL......"<<endl;
cout<<"PRESS
4 TO DISPLAY 2nd POLYNOMIAL......"<<endl;
cout<<"PRESS
5 TO ADD TWO POLYNOMIALS........"<<endl;
cout<<"PRESS
6 TO DISPLAY THE RESULT........"<<endl;
cin>>opt;
node
*n=new node();
switch(opt){
case
0:
break;
case
1:
cout<<"ENTER
THE DEGREE....."<<endl;
cin>>n->degree;
cout<<"ENTER
THE DATA......"<<endl;
cin>>n->data;
ob.append(n);
break;
case
2:
cout<<"ENTER
THE DEGREE....."<<endl;
cin>>n->degree;
cout<<"ENTER
THE DATA......"<<endl;
cin>>n->data;
ob1.append(n);
break;
case
3:
ob.display();
break;
case
4:
ob1.display();
break;
case
5:
ob+ob1;
break;
case
6:
ob.display();
break;
default:
cout<<".........ERROR........"<<endl;
break;
}
}while(opt!=0);
return
0;
}
8
CMSACOR05P: Data Structures Lab
8. Perform Queues operations using Circular Array implementation. Use Templates.