Skip to main content

Posts

DSL

14.Problem statement Write C++ program to store roll numbers of student in array who attended training program in random order. Write function for-  a) Searching whether particular student attended training program or not using linear search and sentinel search.  b) Searching whether particular student attended training program or not using binary search and Fibonacci search.    program #include<iostream> using namespace std; class search {  public:         int n,i,data[50],son[50],sortdata[50],s;  void intake() {     cout<<"Enter No. of Elements=";   cin>>n;   cout<<"\nEnter Elements=\n";   for(i=1;i<=n;i++)   {   cin>>data[i];       son[i]=data[i];   } } void search_lini(int item) {   s=0;   for(i=1;i<=n;i++)   {  if(data[i]==item) ...
Recent posts

OOP

6.Problem statement Develop an object oriented program in C++ to create a database of student  information system containing the following information: Name, Roll number, Class, division, Date of Birth, Blood group, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz constructor, default constructor, Copy constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete. Program #include<iostream> #include<stdio.h> #include<cstring> using namespace std; class personal; static int count; class person {       char *name;       int *rollno,*classno;       char *bloodgroup,*div;                   public:person()              {     ...

OOP

23.Problem statement     C++ Program to Implement Deque in Stl      Program     #include <iostream>     #include <deque>     #include <string>     #include <cstdlib>     using namespace std;     int main()     {         deque<int> dq;         deque<int>::iterator it;         int choice, item;         while (1)         {             cout<<"\n---------------------"<<endl;             cout<<"Deque Implementation in Stl"<<endl;     ...

OOP

21.Problem statement  Write C++ program using STL for implementation of stack & queue using SLL Program #include<iostream> #include<stack> #include<stdlib.h> using namespace std; void display(stack<int>s) { cout<<"\nElement in stack are:- "; while(!s.empty()) { cout<<s.top()<<"  "; s.pop(); } } int main() { stack<int>s; int choice,t; int x; while(1) { cout<<"\n\n*********************************"; cout<<"\n        STACK USING STL"; cout<<"\n*********************************"; cout<<"\n\n1.Push data"; cout<<"\n2.Pop data"; cout<<"\n3.Size of stack"; cout<<"\n4.First Element"; cout<<"\n5.Display Element in stack"; cout<<"\n6.Exit"; cout<<"\nEnter Your choice:- "; cin>>choice;...

OOP

14.Problem statement Crete User defined exception to check the following conditions and throw the exception if the criterion does not meet. a. User has age between 18 and 55 b. User stays has income between Rs. 50,000 – Rs. 1,00,000 per month c.  User stays in Pune/ Mumbai/ Bangalore / Chennai d. User has 4-wheeler  Accept age, Income, City, Vehicle from the user and check for the conditions mentioned above. If any of the condition not met then throw the exception. Program #include<iostream> #include<string.h> using namespace std; class user { public: char vehicle; int salary,age; string city; user() { age=0; vehicle=0; salary=0; } void getdata(); }; void user::getdata() { cout<<"Enter Age Of Person:- "; cin>>age; if(age<18 || age>55) { throw 1; } cout<<"Enter Salary For Permonth:- "; cin>>salary; if(...

DSL

17: Problem statement: Write C++ program to store second year percentage of students in array. Write function for sorting array of floating point numbers in ascending order using a) Insertion sort b) Shell Sort and display top five scores. Program: #include<stdio.h> void insertion(float [],int); void shell(float[],int); int main() {     int i, n,op;     float a[30];     do     {         printf("\n 1)Insertion Sort \n 2) Shell Sort  \n 3) Quit");         printf("Enter your choice :");         scanf("%d",&op);         if(op==1)         {             printf("\n Enter no. of elements :");             scanf("%d",&n);             printf("\n Enter Array elements :");             for(i=0;i...

DSL

16: Problem statement: Write C++ program to store first year percentage of students in array. Write function for sorting array of floating point numbers in ascending order using a) Selection Sort b) Bubble sort and display top five scores. Program: #include<stdio.h> void selection(float[],int); void bubble(float[],int); void main() {     int n,i,op;     float a[30];     do     {         printf("\n 1)Bubble sort \n 2)Selection sort \n 3)Quit");         printf("\n Enter your choice :");         scanf("%d", &op);         if(op==1)         {             printf("\n Enter no. of elements :");             scanf("%d",&n);             printf("\n Enter array elements :");             for(i=0;i<...