28/10/2016

C++ Program For Segregate Even And Odd Numbers.
Problem :- Given An Array A[], Write A C++ Program That Segregates Even And Odd Numbers. The Functions Should Put All Odd Numbers First, And Then Even Numbers .

Solution:-

   
#include<iostream>
using namespace std;
int main()
{
int a[100];
int n,i,j,left=0,right,temp;
cout<<"enter the size of array ";
cin>>n;
cout<<"\n enter the elelment of the array \n";
for(i=0;i<n;i++)
cin>>a[i];
right=n-1;
while(left<right)
{
if(a[left]%2!=0&left<right)
left++;
if(a[right]%2==0&&left<right)
right--;
   if(a[right]%2!=0&&a[left]%2==0&&left<right)
      {
    temp=a[right];
    a[right]=a[left];
    a[left]=temp;
    left++;
   right--;
     }
}
cout<<"segregates of array :";
for(i=0;i<n;i++)
cout<<a[i]<<" ";
return 0;
}

Output :-

                     
C++ Program For Segregates Even And Odd Numbers.
               
C++ Program To Product Array Such That Product Is Equal To The Product Of All The Elements Of An Array
Problem :- Given An Array arr[] Of n Integers, Construct A Product Array prod[] (Of Same Size) Such That prod[i] Is Equal To The Product Of All The Elements Of Arr[] Except arr[i]. Solve It Without Using Division Operator And In O(n).

Solution :-

#include<iostream>
using namespace std;
int main()
{
  int a[100];
  int n,i,j,left[100],right[100],product[100];
  cout<<"Enter The Size Of An Array \n";
  cin>>n;
  cout<<"\nEnter The Elelment Of The Array \n";
  for(i=0;i<n;i++)
  {
  cin>>a[i];
}
 
left[0]=1;
  right[n-1]=1;
  for(i=1;i<n;i++)
  left[i]=a[i-1]*left[i-1];
  for(j=n-2;j>=0;j--)
  right[j]=a[j+1]*right[j+1];
  cout<<"Product Of Array Without Division Operator\n\n";
  for(i=0;i<n;i++)
  {
    product[i]=left[i]*right[i];
    cout<<product[i]<<" ";
      }
    return 0;
}

Output :-


C++ Program To Product Array Such That Product Is Equal To The Product Of All The Elements Of An Array

21/10/2016

C++ Program To Reverse An Array In O(n) Complexity
Problem :- Write A C++ Program To Reverse An Array In O(n);

ARRAY :- Array act to store related data under a single variable name with an index, also known as a subscript. It is easiest to think of an array as simply a list or ordered grouping for variables of the same type. As such, arrays often help a programmer organize collections of data efficiently and intuitively.

Solution :-

#include<iostream>
using namespace std;
int main()
{
  int *a;
  int i,j,temp;
  int n;
  cout<<"Enter The Size of Array \n";
  cin>>n;
  a=new int[n];
  int l=0,h=n-1;
 
cout<<"Enter The Elements of Array \n";
  for(i=0;i<n;i++)
  cin>>a[i];
  while(l<h)
  {
  temp=a[l];
  a[l]=a[h];
  a[h]=temp;
  l++;
  h--;
  }
 
cout<<"\nReverse Array Is\n";
  for(i=0;i<n;i++)
  {
  cout<<a[i]<<" ";
    }
   return 0;
}

Output :-


C++ Program To Reverse An Array In O(n) Complexity

C++ Program To Find Element That Appears More Than N/2 Times.
Problem :- A Majority Element In An Array A[] of Size N Is An Element That Appears More Than N/2 (and hence there is at most one such element). Times. Write a Function Which Takes An Array And Emits The Majority Element (if it exists), Otherwise Prints NONE .

Logic :- We Need to print the Element Which repeat more than N/2 time's example if the size of array is 9 than number should be repeated at-least 5 times 
Let Take A Array 
Size =9
Array Element is 1 1 2 3 1 5 1 1 6

Now N/2 times should be 5 ,So here only 1 is a element only repeated more than N/2.
So Candidate Key is 1. 

Solution :-

#include<bits/stdc++.h>
using namespace std;

int majority(int a[],int size)
{
    int maj_index=0,count=1;
   
for(int i=1;i<size;i++)
    {
      if(a[i]==a[maj_index])
        count++;
    else
      count--;
    if(count==0)
    {
      maj_index=i;
      count=1;
    }
    }
    return a[maj_index];
}
bool ismejority(int a[],int size,int cand)
{
  int count=0;
 
for(int i=0;i<size;i++)
  {
    if(a[i]==cand)
      count++;
  }
  if(count>size/2)
    return 1;
  else
    return 0;
}
int main()
{
  int a[100],i,n;
    
cout<<"Enter The Size of An Array\n";
    cin>>n;
  
  cout<<"\nEnter The "<<n<<" Elemnts \n";
  
  for(i=0;i<n;i++)
  cin>>a[i];  
    
  int cand=majority(a,n);
    
  if(ismejority(a,n,cand))
      cout<<"Candidate key \n"<<cand;
    else
      cout<<"key is not found";
   return 0;
}

Output :-


C++ Program To Find Element That Appears More Than N/2 Times.

10/10/2016

C++ Project For Student Management System (SMS PROJECT) With Source Code
Project:- student management system project in c++ or student management system or online project management tools or online project management software or  Student Management System Project in C++ or School Management Simple C++ Project Source Code or Mini project student database system in c++ source code download or c++ project for student management 

C++ Project For Student Management System (SMS PROJECT) With Source Code


Explanation:- Student Management System is a basic C++ program for education establishments to manage student data and manage many other student-related data needs in a school. In this Student Management System project, the user can create, display, Modify.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.


Tip:- If you have any query feel free to share with me, and if you like my work please share, comments and subscribe for our new and latest post related to programming this will help you update all about new post this Article.

Solution:-

#include<iostream>
#include<string>
#include<conio.h>
#include<stdlib.h>
using namespace std;

int main();
void show_data(int searchkey);    //function used to show data to end-user.
void get_data(int i);          //function used to obtain data from end-user.
void search_student(int searchkey);
void add_student();  //This function is used to add record of new student.
void edit_student(int idnumber);  //function is used to edit existing record.   
void fullscreen();
int ts;

struct student    //Structure student is made to store student attributes.

  int rollno; 
  string name;
  string fname;
  string cell;
  string dob;
  string address;
};

student rec[50]; //This is basic array of defined structure to sore data.
int main()
{
  system("CLS");
  system("color B1");
  int choice; //int variable used to determine which operation user want to do.
  int idnumber; //int variable used to record ID number whih user want to edit.
  int searchkey; //int variable to store student roll_no by which user can search.
 
  cout<<"Enter The Total Number of Student(s)- Max 50: ";
  cin>>ts;

while(ts--)
{
  cout<<"\n\t\tWhat do you want to do?"<<endl;
  cout<<"\t\t----------------------"<<endl;
  cout<<"\t\t1-Add student"<<endl;
  cout<<"\t\t2-Edit student"<<endl;
  cout<<"\t\t3-Search student"<<endl;
  cout<<"\t\t4-Quit Program"<<endl;
  cout<<"\t\t----------------------"<<endl;
  cout<<"Enter your choice: ";

  cin>>choice;
  switch(choice)
{
  case 1: //If user presses 1 then student adding module would be displayed.
  add_student();
  break;
  case 2: //If there are no records in array then it will ask the user to input records first.
  if(rec[0].rollno==0)
{
  cout<<"Please Add sudents first."<<endl;
  system("pause");
main();
}
  else //If records are present in array then it will show table.

  cout<<endl;
  cout<<"--------------------------------------------------------------------------------"<<endl;
  cout<<"---------------------------Student record Table---------------------------------"<<endl;
  cout<<"--------------------------------------------------------------------------------"<<endl; 
  cout<<"ID   "<<"Roll   "<<"Name      "<<"Father\tCell no.      "<<"DOB          "<<"Address\n\n";
  cout<<"--------------------------------------------------------------------------------"<<endl; 

  for(int i=0;i<=ts;i++)
{
  show_data(i); //funtion is called with index value to show data.
  }

  cout<<"--------------------------------------------------------------------------------"<<endl;
  cout<<"Which ID number your want to edit: ";
 
cin>>idnumber;          //Asking the user at which ID he wants to make a change.
   
if(idnumber>ts || idnumber<0) //Validating the ID number.
{      
      cout<<"\nInvalid ID Number."<<endl;
    }
    else
{
      edit_student(idnumber);    //Passing ID number to Edit Function.
    }
}
  break;
 
case 3:
  if(rec[0].rollno==0) //If no record exist then ask the user o enter records first.
{   
  cout<<"Please Add sudents first."<<endl;
  system("pause");
  main();    //Return to main so user can input new record.
  }
  else
{
  cout<<"Enter roll_no of student you want to search: ";
  cin>>searchkey; //roll_no as the search key can be entered by user.
  search_student(searchkey);}
  break;
  case 4:
  return 0; //Terminating the records.
  break;
  default: //Default value for ivalid Input. 
  cout<<"Invalid number."<<endl;
  system("pause");
  main();
  }
}
  return 0;
}

  
void get_data(int i) //Function for receiving data from user and populatiing the variables with values.
{   
  cout<<"Enter student roll number in  format(1XXX): ";
  cin>>rec[i].rollno;
  cout<<"Enter student name: ";
  cin>>rec[i].name;
  cout<<"Enter student's Father name: ";
  cin>>rec[i].fname;
  cout<<"Enter student's cell phone number: ";
  cin>>rec[i].cell;
  cout<<"Enter student's Date of Birth(dd/mm/yyyy): ";
  cin>>rec[i].dob;
  cout<<"Enter student's Address: ";
  cin>>rec[i].address;
}

void show_data(int searchkey) //Function for showing data on the screen.
{    
  int i=searchkey;
  cout<<i<<"    ";
  cout<<rec[i].rollno<<"   ";
  cout<<rec[i].name<<"     ";
  cout<<rec[i].fname<<"\t";
  cout<<rec[i].cell<<"   ";
  cout<<rec[i].dob<<"   ";
  cout<<rec[i].address<<"\n\n";
}

void search_student(int searchkey)
{
  for(int i=0;i<=ts;i++) //Loop thrugh complete array.

  if(rec[i].rollno==searchkey) //If roll number matches to search term.
{   
  cout<<"ID   "<<"Roll   "<<"Name      "<<"Father\tCell no.      "<<"DOB          "<<"Address\n\n";
  show_data(i); //A function is used inside another function.
  }
 
}

void add_student() //This function is used to add record of new student.
{    
  for(int i=0;i<=ts;i++)
{
  get_data(i);    //Loop was processed 5 times to get input for 5 students.
  }
  system("CLS");
  cout<<endl;
  cout<<"--------------------------------------------------------------------------------"<<endl;
  cout<<"---------------------------Student record Table---------------------------------"<<endl;
  cout<<"--------------------------------------------------------------------------------"<<endl;
  cout<<"ID   "<<"Roll   "<<"Name      "<<"Father\tCell no.      "<<"DOB          "<<"Address\n\n";
  cout<<"--------------------------------------------------------------------------------"<<endl;

  for(int i=0;i<=ts;i++)
{
  show_data(i); //Loop was processed for 5 times to show obtained records.
  }
  cout<<"--------------------------------------------------------------------------------"<<endl;
  cout<<"---------------------------------FINISH-----------------------------------------"<<endl;
  cout<<"--------------------------------------------------------------------------------"<<endl;
  system("pause");

  main(); //Return to main function to again show menu.
}

void edit_student(int idnumber) //function is used to edit existing record.
{  
  for(int i=0;i<=ts;i++) //Loop is started.
{  
  if(idnumber==i) //Through loop every value is compared with search term.
{         
  cout<<"\nExisted information about this record.\n\n";
  cout<<"--------------------------------------------------------------------------------"<<endl;
  cout<<"ID   "<<"Roll   "<<"Name      "<<"Father\tCell no.      "<<"DOB          "<<"Address\n\n";
  cout<<"--------------------------------------------------------------------------------"<<endl;
  show_data(i); //Load information for existing record.
  cout<<"\n\nEnter new data for above shown record.\n\n";
  get_data(i);    //Inputing data for that specific record.
  cout<<"\n\nRecord updated successfully."<<endl;
  system("pause");
  main();    //Return to main function.
  }
  }
}


Output:-

C++ Project For Student Management System (SMS PROJECT) With Source Code

C++ Project For Student Management System (SMS PROJECT) With Source Code

C++ Project For Student Management System (SMS PROJECT) With Source Code

Check Other Projects


C++ Project's

1.C++ Program For Tic Tac Toe ( Game Project ) With Source Code

2.C++ Program For School Management System ( SMS Project ) With Source Code

3.C++ Program For HANGMAN ( GAME PROJECT ) With Source Code

4. C++ Program For Casino Game: Number Guessing Program ( GAME PROJECT )

5.C++ Program For Student Report Card ( SRC PROJECT ) With Source Code

Java Project's

1.JAVA Project SMS (School Management System) Using Multiple Classes

2.Java Program For Calculator Using AWT Controls (GUI)