Skip to content

Commit

Permalink
Merge branch 'master' into task2
Browse files Browse the repository at this point in the history
  • Loading branch information
helios1101 committed Oct 4, 2019
2 parents 30cbc00 + 1d1eade commit ae6b567
Show file tree
Hide file tree
Showing 32 changed files with 1,685 additions and 201 deletions.
Binary file added Task1/img/AmitDutta.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/Dharmick.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/IMG_20190209_000932.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/marciokuroki.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/rahulharlalka.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/risheekjain.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/satyam.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/scheleon.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/shubhayans.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/soumyaukil.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Task1/img/sudeepta.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
645 changes: 446 additions & 199 deletions Task1/index.html

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Task2/contributors.md
Expand Up @@ -12,3 +12,10 @@ Start adding Your Names with hosted portfolio.
7. Dureksha Wasala - dcjc29.github.io
8. Vaibhav Vijay - [vaibhavvijay.me](https://vaibhavvijay.me)
9. Baecon - baecon.github.io
10. Muskan Sharma - muskan077.github.io
11. Aniket Anand - aanand2300.github.io
12. Hilmi Biya - hilmibiya.github.io
13. Márcio Kuroki - marciokuroki.github.io
14. Nihal Murmu - nihalmurmu.me
15. Aayush Garg - aayushgarg-03.github.io
16. Shubhayan Saha - https://shubhayans.github.io/
1 change: 1 addition & 0 deletions Task3/JavaScript/hello-world.js
@@ -0,0 +1 @@
console.log('Hello world');
33 changes: 33 additions & 0 deletions Task3/Objective-c/sieveExample.m
@@ -0,0 +1,33 @@
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
int i, j, n = 150, P[151] = { 0, 1 }, prime = 1;

for ( i = 2; i <= n; ++i ) {
P[i] = prime;
for ( j = 2; j < i ; ++j ) {
if ( i % j == 0 )
P[i] = 0;
}
}
printf("Print prime numbers results:\n\n");
for (i = 2; i <= n ; ++i) {
if ( P[i] != 0 )
printf("%i\n", i);
}

printf(" \n");
printf("Print prime numbers original program #results:\n\n");
//Original program referenced.
int p, d, isPrime;
for ( p = 2; p <= 150; ++p ) {
isPrime = 1;
for ( d = 2; d < p; ++d )
if ( p % d == 0 )
isPrime = 0;
if ( isPrime != 0 )
NSLog (@"%i ", p);
}
return 0;
}
43 changes: 43 additions & 0 deletions Task3/cpp/Binary Search.cpp
@@ -0,0 +1,43 @@
#include <iostream>
using namespace std;

// A recursive binary search function. It returns
// location of x in given array arr[l..r] is present,
// otherwise -1
int binarySearch(int arr[], int l, int r, int x)
{
if (r >= l) {
int mid = l + (r - l) / 2;

// If the element is present at the middle
// itself
if (arr[mid] == x)
return mid;

// If element is smaller than mid, then
// it can only be present in left subarray
if (arr[mid] > x)
return binarySearch(arr, l, mid - 1, x);

// Else the element can only be present
// in right subarray
return binarySearch(arr, mid + 1, r, x);
}

// We reach here when element is not
// present in array
return -1;
}

int main(void)
{
int arr[] = { 2, 3, 4, 10, 40 };
int x = 10;
int n = sizeof(arr) / sizeof(arr[0]);
int result = binarySearch(arr, 0, n - 1, x);
if(result!=-1)
cout<<"Element is present at index " << result <<endl;
else
cout << "Element is not present " << endl;
return 0;
}
22 changes: 22 additions & 0 deletions Task3/cpp/Euclidean_gcd.cpp
@@ -0,0 +1,22 @@
#include <bits/stdc++.h>

using namespace std;

// Function to return gcd of two numbers a and b
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}

// Driver Code
int main()
{
int a, b;
cout<<"Enter any 2 numbers to find their gcd: ";
cin>>a>>b;

cout << "GCD(" << a << ", " << b << ") = " << gcd(a, b) << endl;
return 0;
}
75 changes: 75 additions & 0 deletions Task3/cpp/FloydCycleLL
@@ -0,0 +1,75 @@
// C++ program to detect and remove loop
#include <bits/stdc++.h>
using namespace std;

struct Node {
int key;
struct Node* next;
};

Node* newNode(int key)
{
Node* temp = new Node;
temp->key = key;
temp->next = NULL;
return temp;
}

void printList(Node* head)
{
while (head != NULL) {
cout << head->key << " ";
head = head->next;
}
cout << endl;
}


void detectAndRemoveLoop(Node* head)
{
// If list is empty or has only one node
// without loop
if (head == NULL || head->next == NULL)
return;

Node *slow = head, *fast = head;

slow = slow->next;
fast = fast->next->next;

while (fast && fast->next) {
if (slow == fast)
break;
slow = slow->next;
fast = fast->next->next;
}

if (slow == fast) {
slow = head;
while (slow->next != fast->next) {
slow = slow->next;
fast = fast->next;
}

fast->next = NULL; /* remove loop */
}
}

int main()
{
Node* head = newNode(50);
head->next = head;
head->next = newNode(20);
head->next->next = newNode(15);
head->next->next->next = newNode(4);
head->next->next->next->next = newNode(10);

head->next->next->next->next->next = head->next->next;

detectAndRemoveLoop(head);

printf("Linked List after removing loop \n");
printList(head);

return 0;
}
179 changes: 179 additions & 0 deletions Task3/cpp/MenuDrivenFileManipulation.cpp
@@ -0,0 +1,179 @@
#include<iostream>
#include<cstring>
#include<fstream>

using namespace std;


class Stud;
class MyException
{
char str1[50];
int what;

public:
MyException()
{
*str1 =0;
what =0;
}
MyException (const char s[], int x)
{
strcpy(str1,s);
what = x;

}
void printInfo(MyException e)
{
cout<<e.str1;
cout<<e.what;

}
//friend class Stud;
};

class Stud
{
int rollNo;
int Age;
int yoj;
public:
void setInfo(int x, int y, int z)
{
rollNo =x;
Age =y;
yoj =z;
}
void displayInfo()
{
cout<<"\t"<<rollNo;
cout<<"\t"<<Age;
cout<<"\t"<<yoj<<endl;
}

};
Stud createRecord();
void displayColHead()
{
cout<<"\t rollNo";
cout<<"\t Age";
cout<<"\t yoj"<<endl;

}
void menu()
{
cout<<"1.Creation "<<endl;
cout<<"2.Display "<<endl;
cout<<"3.Appending "<<endl;


}
void createFile()
{
Stud s;
int opt;
ofstream out;
out.open("stud.dat",ios::out|ios::binary);

while(opt)
{
s=createRecord();
out.write((char*)&s,sizeof(s));
cout<<"Any more records?(1/0)";
cin>>opt;

}
out.close();

}

Stud createRecord()
{
int a,b,c;
int flag=0;
Stud s;
while(!flag)
{
try
{
flag=1;
cout<<" enter values for roll no and age and yob: "<<endl;
cin>>a;
cin>>b;
cin>>c;

if (a<=0)
throw MyException("Roll No cannot be negative....",a);
if (b<15)
throw MyException("Age cannot be less than 15::", b);

if (c >2019)
throw MyException("jOINING Year Cannot be greater than current year :: ",c);
}
catch(MyException e)
{
e.printInfo(e);
flag =0;
}
if (flag==1){
s.setInfo(a,b,c);
return s;
}
}
}

void displayFile()
{
Stud s;
ifstream in;
in.open("stud.dat",ios::in|ios::binary);

in.read((char *)&s,sizeof(s));
while(!in.eof())
{
s.displayInfo();
in.read((char *)&s,sizeof(s));
}
}

void appendRecord()
{
Stud s;
fstream out;
out.open("stud.dat",ios::app|ios::out|ios::binary);
s=createRecord();
out.write((char *)&s,sizeof(s));
out.close();
}


int main()
{

int opt=1;
while(opt)
{
menu();
cout<<"Enter ur option...";
cin>>opt;
if (opt==1)
{
createFile();
cout<<"File created successfully ....."<<endl;
}
if (opt==2)
{
displayFile();
cout<<"File displayed successfully ....."<<endl;
}
if (opt==3)
{
appendRecord();
cout<<"File appended successfully ....."<<endl;
}
}
}




0 comments on commit ae6b567

Please sign in to comment.