You are on page 1of 5

Sri Krishna College of Engineering and Technology

Name :Rithan Karthik Email :22mct126@skcet.ac.in


Roll no:22mct126 Phone :7538868717
Branch :SKCET Department :MCT
Batch :2022_26 Degree :BE-Mechatronics

2022_26_I_Problem Solving and Programming using CPP_IRC

IRC_CPP_Cod_1Darray

Attempt : 2
Total Mark : 50
Marks Obtained : 30

Section 1 : Coding

1. Problem Statement:

Version Management System

A version Management system (VMS) is a repository of files, often the files


for the source code of computer programs, with monitored access. Every
change made to the source is tracked, along with who made the change,
why they made it, and references to problems fixed, or enhancements
introduced, by the change.

In this problem, we will consider a simplified model of a development


project. Let's suppose that there are N source files in the project. All the
source files are distinct and numbered from 1 to N.
A VMS which is used for maintaining the project contains two sequences
of source files. The first sequence contains M source files that are ignored
by the VMS. If a source file is not in the first sequence, then it's considered
to be unignored. The second sequence contains K source files that are
tracked by the VMS. If a source file is not in the second sequence, then it's
considered to be untracked.

A source file can either be or not be in any of these two sequences. Your
task is to calculate two values: the number of source files of the project,
that are both tracked and ignored, and the number of source files of the
project, that are both untracked and unignored.

Answer
-
Status : Skipped Marks : 0/10

2. Problem Statement :

Maximum Element in an Array

You are playing the PUBG game and you entered into the Bootcamp. There
you viewed the dropbox which was filled with guns. you have to choose the
biggest gun in the dropbox. Find the biggest gun and you will get the
chicken dinner.

Answer
// You are using GCC
#include<iostream>
using namespace std;
int main()
{
int N;
cin>>N;
int array[N];
for(int i=0;i<N;i++)
cin>>array[i];
int large;
large=array[0];
for(int i=1;i<N;i++)
{
if(array[i]>large)
large=array[i];
}
cout<<large<<" is the maximum element in the array.";

Status : Correct Marks : 10/10

3. Problem Statement :

Array median

Write a program to find the median of the elements in the array. The
Median is the middle value in the sorted list. If there are an even number of
elements in the list, the median is the mean of the 2 middle values.

Answer
// You are using GCC
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int array[n];
for(int i=0;i<n;i++)
cin>>array[i];
sort(array,array+n);
float median;
if(n%2==0)
median=(array[n/2]+array[n/2-1])/2.0;
else
median =array[n/2];
cout<<fixed<<setprecision(1);
cout<<"Median = "<<median;

Status : Correct Marks : 10/10


4. Problem Statement :

Count distinct elements

Howard Wolowitz and Rajesh Koothrapalli were developing a plan to find


the ideal woman for Sheldon Cooper. There were puzzles, translations, and
questions to check a person's intelligence. One such question was to come
up with a C++ program to count the number of distinct elements in an
array. Ramona Nowitzki is a postdoctoral researcher and former graduate
student of Caltech who is a huge fan of Sheldon's work and she wanted to
impress Sheldon by writing a program to count the number of distinct
elements in an array. Can you help Ramona?

Answer
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int array[n];
for(int i=0;i<n;i++)
cin>>array[i];
int visited[n]={0};
int count=0;
for(int i=0;i<n;i++)
{
if(visited[i]==0)
{
for(int j=i+1;j<n;j++)
{
if(array[i]==array[j])
{
visited[j]=1;
}
}
count++;
}
}
cout<<"There are "<<count<<" distinct element in the array.";
}

Status : Correct Marks : 10/10

5. Problem Statement :

Array deletion

Given an array with 'n' elements, Suresh wants to delete an element at a


particular position in the array. Help him in deleting the element and
displaying the updated array.

Answer
-
Status : Skipped Marks : 0/10

You might also like