Posts

Showing posts from October, 2019

Binary Search

//-************************************// Author:- Ketan Kulkarni Version:- Eclipse IDE //************************************// #include<iostream> Using namespace std; Int main() { Int mid,key;   Int n; Int roll_no[30]; int flag=0; cout<<"\n Enter Number of Students:";   cin>>n; cout<<"---------------------Roll numbers are in ordered list------------------------"; cout<<"\nEnter"<<n<<"Roll Numbers:\n";   for(inti=0;i<n;i++) { cin>>roll_no[i]; } cout<<"\nEnter Roll Number to Search:"; cin>>key; int low=0; int high=n-1; while(low<=high) { mid=(low+high)/2; if(key==roll_no[mid]) { cout<<"\nRollno."<<key<<"attended Program\n\n"; flag=1; break; } if(key<roll_no[mid]) { high=mid-1; } else { low=mid+1; } } if(flag==0) cout<<"\n Rollno."...

Magic Square Program

/*          Name: Magic Square.           Author: Ketan Kulkarni           Date: 17-10-19 00:11           SPPU assignment no.3           Description: Write a c++ program to implement the magic square. */ #include <iostream> using namespace std; int main() {           int i,j,l,k,size=3,row,col,m,nr,nc;           int matrix[3][3];           for(i=0;i<3;i++)           {                     for(j=0;j<3;j++)          ...

Popular posts from this blog

Packages and Interfaces in java

Magic Square Program