Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soumyadeep Das #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Q1_CP.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include<bits/stdc++.h>
#define MAX 100
using namespace std;
int main()
{
int a1[MAX];
int a2[MAX];
int n;
cout<<"\n Enter the size of an array:-";
cin>>n;
int i;
cout<<"\n Enter the element of an array:-\n";
for(i=0;i<n;i++)
{
cin>>a1[i];
}
int ind=0;
//EVEN NUMBER
for(i=0;i<n;i++)
{
if(a1[i]%2==0)
{
a2[ind]=a1[i];
ind++;
}

}
//ODD NUMBER
for(i=0;i<n;i++)
{
if(a1[i]%2==1)
{
a2[ind]=a1[i];
ind++;
}

}
cout<<"\n***************OUTPUT******************\n";
for(i=0;i<n;i++)
{
cout<<a2[i]<<"\t";
}

return 0;

}
36 changes: 36 additions & 0 deletions Q2_CP.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
#include<stdio.h>
using namespace std;
#define MAX 100
int main()
{
int arr[MAX];
int i,j,n,c=0;
cout<<"Enter the Size of the Array\n";
cin>>n;
cout<<"Enter the elements of an array\n";
for(i=0;i<n;i++)
{
cin>>arr[i];
}
for(i=0;i<=9;i++)
{
c=0;
for(j=0;j<n;j++)
{
if(i==arr[j])
{
c++;
}
}
if(c!=0)
{
cout<<i<<"-"<<c;
cout<<"\n";
}

}


return 0;
}
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
# Competitive Programming Assignment

Solve the following problems:
1. Given an array of size n arrange the array in such a way that all even numbers comes before all odd numbers and the order should be maintained
Example - 13 25 6 24 45 2
Output - 6 24 2 13 25 45


2. Given an array of size n print the array element and it's frequency. (Order not mandatory)
Example - 2 4 2 2 3 3 3 5
Output:
2 - 3
3 - 3
4 - 1
5 - 1

# Instructions to upload

- Fork the repository
- Create a new branch (with your name)
- Upload files in the new branch.
- Create a pull request.

# Soumyadeep Das
# BCA 1B
# 211001102090