Leadership & Nuclear Weapons Analysis
Leadership & Nuclear Weapons Analysis
A leader should have a power of intuition and taking precautionary steps in order to tame the
challenging situations efficiently and successfully. Intuition, being one of the best characteristics
of a leader, forecasts everything waited. It helps the respective leader to apprise public, in
advance, a situation to cause its vigorous impact on the people perilously or constructively. In
other words a good leader can arouse the sentiments against as well as in favour of individual,
regime and power.
Overall, leadership involves being an effective communicator, being trustworthy, and being
ambitious. The leader needs to be able to connect on some level with his followers. His
followers need to be able to depend on him. Lastly, he needs the inner motivation to want to
lead the group of people.
Those technologies have now developed into nuclear weapons. The destructive power of a
nuclear weapon is just one threat to consider. The radioactive fallout from such a weapon can
cause long-term consequences for a population that was close to the explosion. Radiated soil,
weapon debris, and radioactive particles falling from the sky are all threats that must be taken
seriously, which means a nation with nuclear weapons provides a great threat to a potential
invader.
If enough nuclear weapons are launched and allowed to detonate, however, then life as we
know it on our planet will cease to exist. Any survivors would be forced to endure unthinkable
conditions.
Here are the essential pros and cons of nuclear weapons to consider.
The pros and cons of nuclear weapons show that they can serve as a deterrent and support
“positive” technologies. There is just one question that continues to remain unanswered: what
will happen if someone finally calls the bluff and attacks a nation with nuclear capabilities? It is
the potential answer to that questions which should cause everyone to pause and consider the
continued need for these weapons.
Education is a lasting process. Academic performance in primary education plays a crucial role
in obtaining further educational opportunities. Thus, it is necessary to examine how family
background affects children’s academic achievement at an early stage. There are two pathways
through which family influences children’s academic performance. Firstly, parents compete for
high-quality educational opportunities for their children and better educational opportunities
lead to better academic performance. Secondly, parenting behavior and educational support
for their children could cultivate children’s learning habits and affect academic performance.
We also find urban students’ academic performance are more heavily affected by their families’
socioeconomic status compared with rural students.
Parents and family members play a vital role in the development of an individual. This can be
explained using biological and genetic factors. When a learner comes from a family of sharp
parents , this trait can be genetically inherited by the student and becomes sharp in school .
Friends have got both direct and indirect influence on the achievement of an individual
academically. Friends who positively influence the learner will increase his or her performance
while the negative influencer will decrease the performance of the learner
Society plays a very significant role in shaping the behavior of an indivual. One develops
positive or negative behavior depending upon the kind of exposure one has got in the society
around him. This will provide cool environment for learning which will increase the
performance of the learner.
It is good to note that the good achievement of an individual depends on him or her. Without
parents we would not come in to this world, without friends we not come across enjoyment,
fun, hard work, trust, showing good path, helping nature etc. But parents are only main role in
the achievement of any person. Without their care, love, willpower no one cannot do anything
but I know that few don't have parents and few are handicaps, rumors etc but now-a-days they
are also showing their talents hidden in them, they're also achieving great things in their lives.
The first step in balancing your work and personal life is recognizing that it is not just going to happen—
you have to be proactive and work at it, and the time to do so is now.
Finding a balance between your work and your personal life does not just happen, according to
professionals in the field of physician well-being. You have to work at it, and the time to do so is now.
“Balance requires effort, planning, and tradeoffs,” says John Schorling, MD, MPH, internal medicine
professor and director of physician wellness programs at the University of Virginia School of Medicine.
Referring to a psychology of postponement attributed to physicians, Schorling comments, “We always
think life will be better in the next phase—when I'm out of residency, after my fellowship, as soon as my
practice is built up.” But, Schorling stresses, life will never change if you are waiting for the future. The
first step in finding work-life balance is recognizing that it is not just going to happen—you have to be
proactive.
Here are some ways to create a better work-life balance, as well as how to be a supportive manager.
When you hear "work-life balance," you probably imagine having an extremely productive day at work,
and leaving early to spend the other half of the day with friends and family. While this may seem ideal, it
is not always possible.
Don't strive for the perfect schedule; strive for a realistic one. Some days, you might focus more on
work, while other days you might have more time and energy to pursue your hobbies or spend time
with your loved ones. Balance is achieved over time, not each day.
Although work is an expected societal norm, your career shouldn't be restraining. If you hate what you
do, you aren't going to be happy, plain and simple. You don't need to love every aspect of your job, but
it needs to be exciting enough that you don't dread getting out of bed every morning.
Your overall physical, emotional and mental health should be your main concern. If you struggle with
anxiety or depression and think therapy would benefit you, fit those sessions into your schedule, even if
you have to leave work early or ditch your evening spin class. If you are battling a chronic illness, don't
be afraid to call in sick on rough days. Overworking yourself prevents you from getting better, possibly
causing you to take more days off in the future.
Cutting ties with the outside world from time to time allows us to recover from weekly stress, and gives
us space for other thoughts and ideas to emerge. Unplugging can mean something simple like practicing
yoga instead of checking work emails.
5. Take a vacation.
Sometimes, truly unplugging means taking vacation time and shutting work completely off for a while.
Whether your vacation consists of a one-day staycation or a two-week trip to Goa, it's important to take
time off to physically and mentally recharge.
While your job is important, it shouldn't be your entire life. You were an individual before taking this
position, and you should prioritize the activities or hobbies that make you happy
When planning time with your loved ones, create a calendar for romantic and family dates. It may seem
weird to plan one-on-one time with someone you live with, but it will ensure that you spend quality
time with them without work-life conflict. Just because work keeps you busy doesn't mean you should
neglect personal relationships.
Set boundaries for yourself and your colleagues, to avoid burnout. When you leave the office, avoid
thinking about upcoming projects or answering company emails. Consider having a separate computer
or phone for work, so you can shut it off when you clock out. If that isn't possible, use separate
browsers, emails or filters for your work and personal platforms.
Pay attention to when you are most productive at work and block that time off for your most important
work-related activities. Avoid checking your emails and phone every few minutes, as those are major
time-wasting tasks that derail your attention and productivity. Structuring your day can increase
productivity at work, which can result in more free time to relax outside of work.
Work-life balance will mean different things to different people because, after all, we all have different
life commitments. In our always-on world, balance is a very personal thing, and only you can decide the
lifestyle that suits you best.
Education is one of the reasons for living in a big town or city. Both cities and small towns have
good and bad schools. However, there are a lot of options in a big city. Most small towns have
one or two high schools. On the other hand, a big city has more schools than that. In a big city,
you have the option for your career making field. A Big city has universities, colleges and schools.
Because of that you can go to more sporting venues, like NBA Basketball games, NBA Football
games, as well as many minor league or major league sporting events. Small towns offer you
local high school sports. When you live in a big city, you have much greater access to a variety of
entertainment venues, and you are exposed to all sorts of different cultures. Cities also have all
sorts of music festivals, comedy festivals, and other events that happen on a fairly regular basis.
By contrast, small towns generally don’t have nearly as much variety. Furthermore, Small towns
rarely have a formal public transportation system. People must need to buy their own vehicle or
depend on others for a ride.
Even though I have never lived in a city, I think life is better in a small town because the
community is close knit. Small towns have less crime and less traffic as well.
In a small town everybody seems to know each other. Strangers smile at you when you pass
them in public. It also seems like people in small towns are more willing to reach out and help
you when you are in need.Cities seem to have a lot of crime and in small towns crime is very
low. You don't have to worry about locking doors or closing windows and you are less likely to
get mugged or robbed. Children are also safe walking to school alone or playing outside with
little or no supervision.
Traffic is another great thing about living in a small town. It takes less time to drive from one
end of town to the other than it does in the city. You also don't have to wait very long at
intersections or spend much time searching for a free parking spot.
• Tradition contributes a sense of comfort and belonging. It brings families together and
enables people to reconnect with friends.
• Tradition reinforces values such as freedom, faith, integrity, a good education, personal
responsibility, a strong work ethic, and the value of being selfless.
• Tradition provides a forum to showcase role models and celebrate the things that really
matter in life.
• Tradition offers a chance to say “thank you” for the contribution that someone has
made.
• Tradition enables us to showcase the principles of our Founding Fathers, celebrate
diversity, and unite as a country.
• Tradition serves as an avenue for creating lasting memories for our families and friends.
• Tradition offers an excellent context for meaningful pause and reflection.
As leaders, role models, and parents, we must strive to utilize every opportunity available to us
to reinforce the values and beliefs that we hold dear. The alternative to action is taking these
values for granted. The result is that our beliefs will get so diluted, over time, that our way of
life will become foreign to us. It’s like good health. You may take it for granted until you lose it.
If we disregard our values, we’ll open our eyes one day and won’t be able to recognize “our
world” anymore. The values that support the backbone of our country, our family, and our faith
will have drifted for so long that the fabric of our society will be torn.
Teach your generations about your roots, culture, traditions and customs however make them
understand to follow only those which are practically feasible.
I think science is a part of culture. There is no sense facing them each other. They require each
other: without culture science cannot exist and at a certain point of cultural evolution science
appears and develops parallel with culture. Both are manifestation of human brain, creativity
and human relationship to the environment as well as the universe of facts and ideas.
Even while studying inside the class, they feel so burdened; they have come to dislike
education. as a result, there is hardly any creativity left in our country. Every year all the
illustrious prizes for creativity are won by non-Indians or Indians living in advanced countries.
Our educationists must rethink and revise the curriculum to encourage creativity and
imagination in children.
With each passing day, education is becoming more difficult and the system is getting stricter.
With such heavy rules and regulations in academics, students hardly have the opportunity to
dream and imagine. Children are known for their imagination and it is due to imagination that
they can explore new creative arenas. This is creating extremely methodical individuals but the
true meaning of education is somewhat missing. Education teaches us to be more vocal about
our likings and disliking and improves our imaginative skill and creativity.
Weapons are used to increase the efficacy and efficiency of activities such as hunting, crime,
law enforcement, self-defense, and warfare. In broader context, weapons may be construed to
include anything used to gain a tactical, strategic, material or mental advantage over an
adversary or enemy target.
The time is right for a fundamental rethinking of the role of nuclear weapons in national
defense and of the composition of our nuclear forces. The Cold War is over, but it has been
replaced by new threats to our national security. Technology, here and abroad, is inexorably
advancing, creating both dangers and opportunities for the United States. This paper analyzes
the future role of nuclear weapons in national security, describes the roles and limitations of
advanced conventional weapons in meeting strategic needs, and suggests several alternate
scenarios for future U.S. nuclear forces.
The principal role of nuclear weapons is to deter potential adversaries from an attack on the
United States, our allies, or our vital interests. Russia maintains very large strategic and tactical
nuclear forces. China is actively modernizing its nuclear arsenal. India and Pakistan have
dramatically demonstrated the ability of midlevel technology states to develop or acquire
nuclear weapons. There are grave concerns about the future proliferation of nuclear weapons
among such countries as North Korea, Iraq, and Iran. The nuclear age is far from over.
Advances in conventional weapons technology suggest that by 2020 precision long-range
conventional weapons may be capable of performing some of the missions currently assigned
to nuclear weapons. Today, uncertainty in the location of road mobile missiles carrying
weapons of mass destruction might require a nuclear weapon for assured destruction. Future
real-time imagery and battle management, combined with precision strike long-range missiles,
may mean that a conventional weapon could effectively destroy such targets.
Some targets require the energy of a nuclear weapon for their destruction. However, precision
targeting can greatly reduce the nuclear yield required to destroy such targets. Only a relatively
few targets require high nuclear yields. Advantages of lower yields include reduced collateral
damage, arms control advantages to the United States, and the possibility that such weapons
could be maintained with higher confidence and at lower cost than our current nuclear arsenal.
Now is the time to reexamine the role and composition of our future nuclear forces. New
technologies take at least a decade to move from the concept stage to the point where we can
rely on them for our nations defense. And, advance planning is already under way for the
replacements of our nuclear capable missiles, aircraft, and sub-marines. Prudent thought given
to this crucial subject will reap great dividends for the United States and for peace in the world.
Q) 1
11
111
void patternPrint(int num)
{
int print=1,i,j;
for(i=0;i<num;i++)
{
for(j=0;j<=i;j++);
{
printf(“%d “,print);
}
printf(“\n”);
}
}
Ans: semicolon after for loop
void patternPrint(int num){
int print=1,i,j;
for(i=0;i<num;i++) {
for(j=0;j<=i;j++)
{
printf(“%d “,print);
}
printf(“\n”);
}
}
Q) return true if given date is july 5th.
int checkBirthDay(char* month, int day)
{
if((strcmp(month, "July")) || (day == 5))
return 1;
else
return 0;
}
Ans: both conditions has to be satisfied. so and operator has to be
applied.
strcmp return 0 when equal. so check 0 or not
int checkBirthDay(char* month, int day)
{
if((strcmp(month, "July")==0) && (day == 5))
return 1;
else
return 0;
}
Q) find x power y, given function that computes positive power only.
float allExponent(int baseValue,int exponentValue){
float res=1;
if(exponentValue >=0)
{
res=(float) positiveExponent(baseValue,exponentValue);
}
else
{
//write your code here for negative value of exponent
}
return res;
}
Ans: 1/x equals to x^-1.
float allExponent(int baseValue,int exponentValue)
{
float res=1;
if(exponentValue >=0)
{
res=(float) positiveExponent(baseValue,exponentValue);
}
else
{
res=(float) positiveExponent(baseValue,-exponentValue);
res=1/res;
}
return res;
}
Q) check whether given points form a triangle or not
int isTriangle(Point *P1, Point *P2,Point *P3)
{
//write your code here
}
Example2:
Input: 8, [0, 0, 0, 1, 0, 1, 1, 1]
Output: 12300045
Example2:
Input: {day:01, month:06, year:2011}
{day:01, month:06, year:2012}
Output: 366
Similarly, count number of days before date2. Let this count be n2.
Finally return n2-n1
int differefence_in_dates(Date *date1,Date *date2)
{
long int n1,n2;
int i,y;
int monthDays[12] = {31, 28, 31,30, 31, 30,31, 31, 30, 31, 30, 31};
n1 = date1->year*365 + date1->day;
for (i=0; i<date1->month - 1; i++)
n1 += monthDays[i];
y = date1->year;
if (date1->month <= 2)
y--;
n1 += y/4 - y/100 + y/400;
n2 = date2->year*365 + date2->day;
for (i=0; i<date2->month - 1; i++)
n2 += monthDays[i];
y = date2->year;
if (date2->month <= 2)
y--;
n2 += y/4 - y/100 + y/400;
Example1:
Input: 5, 3, [0, -3, 1, -6, 2]
Output: 0
Example2:
Input: 5, 3, [11, 2, 3, 14, 5]
Output: 2
count+=1;
}
return count;
}
Q) remove an element at a given index from an array
Example1:
Input: 9, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]
Output: 1 2 3 5 6 7 8 9
Example2:
Input: 6, 6, [1, 2, 3, 4, 5, 6]
Output: 1 2 3 4 5 6
Example:
Input: 5, [1, 5, 2, 7, 9]
4, [10, 4, 6, 3]
Output: 10
Example:
Input: 8, [0, 1, 0, 0, 1, 1, 1, 0]
Output: 0 1 1 0 1 0 0 1
Ans: find the distance between three points. let them be a,b,c.
if a2+b2=c2 then it will be right triangle
max = (d1>d2)?(d1>d3?d1:d3):(d2>d3)?d2:d3;
min = (d1<d2)?(d1<d2?d1:d3):(d2<d3)?d2:d3;
mid = (d1+d2+d3)-(min+max);
if(max*max==min*min+mid*mid)
return 1;
else
return 0;
}
Q) find number of occurrences of a given element.
Example:
Input: 8, [1,2,2,2,5,5,4,4]
Output: 3
int main()
{
printcolor(3);
return 0;
}
Ans: break has to be used along with each case
#include<stdio.h>
int main(void)
{
printpattern(5);
return 0;
}
Ans: i loop has j loop and new line printing as its body.
So enclose them in braces
int printpattern(int n)
{
int i,j,print =1;
for(i=1;i<=n;i++)
{
for(j=1;j<=2 * i;j++)
{
printf("%d",print );
}
printf("\n");
}
}
int main(void)
{
printpattern(5);
return 0;
}
Q) reverse the elements of given array
#include <stdio.h>
int arrayReverse(int *arr,int len)
{
int i,temp,originallen=len;
for(i=0;i<=originallen/2;i++)
{
temp=arr[len-1];
arr[len-1]=arr[i];
arr[i]=temp;
len+=1;
}
return arr;
}
int main(void) {
int a[]={1,2,3,4,5,6},*b,i;
b=arrayReverse(a,6);
for(i=0;i<6;i++)
printf("%d ",b[i]);
return 0;
}
Ans: len has to move towards right. So decrement it.
No of swapping should be size/2. So remove ‘=’ in condition
as started from 0
#include <stdio.h>
int arrayReverse(int *arr,int len)
{
int i,temp,originallen=len;
for(i=0;i<originallen/2;i++)
{
temp=arr[len-1];
arr[len-1]=arr[i];
arr[i]=temp;
len-=1;
}
return arr;
}
int main(void) {
int a[]={1,2,3,4,5,6},*b,i;
b=arrayReverse(a,6);
for(i=0;i<6;i++)
printf("%d ",b[i]);
return 0;
}
Q) print the grade given score
#include<stdio.h>
char checkGrade(int score)
{
if(score<=60)
return 'D';
else if((61>=score)&&(score<=75))
return 'C';
else if((76>=score)&&(score<=90))
return 'B';
else
return 'A';
}
int main()
{
int score;
scanf("%d",&score);
printf("%c", checkGrade(score));
return 0;
}
Ans: range condition should be <= and >= combination
#include<stdio.h>
char checkGrade(int score)
{
if(score<=60)
return 'D';
else if((61<=score)&&(score<=75))
return 'C';
else if((76<=score)&&(score<=90))
return 'B';
else
return 'A';
}
int main()
{
int score;
scanf("%d",&score);
printf("%c", checkGrade(score));
return 0;
}
Q) find difference in seconds between two times
TESTCASE
TestCase1:
Input:
Time:1:58:42, Time:2:1:45
Expected Return values:
183
Testcase 2
Input:
Time:3:49:57, Time:2:45:57
Expected Return Values
3600
void printPattern(int n)
{
// write your code here
}
#include <stdio.h>
void printPattern(int n){
int i,j;
for(i=1;i<=n;i++) {
for(j=1;j<=i;j++) {
printf("%d",j);
}
for(j=i-1;j>=1;j--) {
printf("%d",j);
}
printf("\n");
}
}
(Or)
void printPattern(int n)
{
int i,j;
long int num=0;
for(i=0;i<n;i++)
{
num=num*10+1;
printf("%ld\n", num*num);
}
}
int main()
{
printPattern(8);
return 0;
}
Q) The method deleteDuplicate(int len, int arr[]) takes an array as
an input. it is supposed to remove duplicate integers from the
input array arr such that for each distinct integer the first occurrence
is retained and all the duplicates elements following it are removed
Example:
Input: (2,3,2,2,5,6,6,7)
Output: 2, 3, 5, 6, 7
int* deleteDuplicate (int *arr, int len)
{
int i,j,k=0;
for(i=0;i<len;i++)
{
for(j=i+1;j<len;j++)
{
if(arr[j]==arr[i])
{
arr[k]=arr[k+1];
}
len=len-1;
count=count+1;
j=i;
}
}
return arr;
}
Ans: when a match occurs not a single element all the following elements
has to be shifted right one position.
Count has to be increased, size has to be decreased, j has to be updated
to j-1 when only match occurs
#include <stdio.h>
int count=0;
int* deleteDuplicate (int *arr, int len)
{
int i,j,k=0;
for(i=0;i<len;i++)
{
for(j=i+1;j<len;j++)
{
if(arr[j]==arr[i])
{
for(k=j;k<len;k++)
arr[k]=arr[k+1];
len=len-1;
count=count+1;
j--;
}
}
}
return arr;
}
int main(void)
{
int a[]={2,3,2,2,2,6,6,7},i,*b;
b=deleteDuplicate(a,8);
for(i=0;i<8-count;i++)
printf("%d ",b[i]);
return 0;
}
Q) Given a string str, write a program to eliminate all the vowels
from the given string.
EXAMPLE:
Input =”abcdefghijklmnopqrstuvwxyz”
0utput="bcdfghjklmnpqrstvwxyz”
int main(void) {
char str[]="abcdef",*s;
s=removeVowel(str);
printf("%s",s);
return 0;
}
Q) Pyramid of alphabets
a
bcd
efghi
jklmnop
void printPattern(int n){
// write your code here
}
#include<stdio.h>
void printPattern(int n){
int i,j;
char ch='a';
for(i=1;i<=n;i++) {
for(j=1;j<=n-i;j++)
printf(" ");
for(j=1;j<=2*i-1;j++)
printf("%c",ch++);
printf("\n");
}
}
int main(void)
{
printPattern(3);
return 0;
}
Q) You have to encrypt a non-empty string phrase.
The encryption adds a 'cyclic shift' to each letter where the value of
this 'cyclic shift' is decided by the position of the letter from the end
of its word. The shift value for each letter of a word is its index value
(starting from 0) from the right-most character of the word.
EXAMPLE:
The shift values in 'yum feed' will be
yum: m->0, u->1, y->2
feed: d->0, e->1, e->2, f->3
which gives the encryption avm igfd
Here, adding the shift with value 0 to letter 'm' gives 'm' + 0 = m;
values 1 to 'u' gives 'u' + 1 = v and values 2 to 'y' gives 'y' + 2 = a
Note that the shift wraps around on reaching the end of the
alphabets, i.e., the shift values for 'y' as shown above is 'a'.
TEST CASE1:
Input: 3 16 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0
Expected Return Value: 11
TESTCASE 2:
Input:2 9 2 3 1 3 2 1 4 3 2
Expected Return Value: 7
int main()
{
int misscount,pages[]={7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0};
misscount=LruCountMiss(3,pages,16);
printf("%d ",misscount);
}
Q) The methods GetDigitSum(int *arr,int len) accepts an integers array
arr. it is supposed to calculate the sum of digits of the smallest elements
in the input array. It returns 1 if the calculated sum is even and returns
0 otherwise. However there is a compliation error in the code your task
is to fix it so that the program works for all the input values.
Note: The methods getdigitSum uses another method
getSum(int num) which returns the sum of the digits of the
input number num. Write code for that function
#include<stdio.h>
int getDigitSum(int *arr,int len)
{
int result;
for(int i=0;min=arr[0];i<len;i++)
{
if(arr[i]<min)
min=arr[i];
}
result=getSum(min);
if(result%2==0)
return 1;
else
min==arr[j];
}
int getSum(int num){
// write your code here
}
int main(){
int a[]={1423,567,897,426,765},s;
s=getDigitSum(a,5);
printf("%d",s);
}
Ans:
#include<stdio.h>
int getSum(int num);
int getDigitSum(int *arr,int len){
int result,min,i;
for(i=0,min=arr[0];i<len;i++) {
if(arr[i]<min)
min=arr[i];
}
result=getSum(min);
if(result%2==0)
return 1;
else
return 0;
}
int getSum(int num)
{
int rem,sum=0;
while(num)
{
rem=num%10;
sum+=rem;
num/=10;
}
return sum;
}
int main()
{
int a[]={1423,567,897,426,765},s;
s=getDigitSum(a,5);
printf("%d",s);
}
Telegram: https://t.me/campusdrive
Logical error
Problem (1 ):
The function/method countDigits return an integer representing the remainder when the given number
is divided by the number of digits in it.
The function/method countDigits accepts an argument-num,an integer representing the given number.
The function/method countDigits compiles code successfully but fails to get the desirable result for
some test cases due to logical errors. Your task is to fix the code so that it passes all the test cases.
---------------------------------------
Test case 1:
Input: 782
Test case 2:
Input: 21340
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
---------------------------------------
int count=0;
while(num!=0)
num=num/10;
count++;
return (num%count);
---------------------------------------
solution:
int count=0,temp=num;
while(temp!=0)
temp=temp/10;
count++;
return (num%count);
---------------------------------------
Problem ( 2 ):
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
The function/ method arrayReverse modify the input list by reversing its element. The function/method
arrayReverse accepts two arguments - len an integer representing the length of the list and arr, list of
integers representing the input list respectively
The function/method arrayReverse compiles code successfully but fails to get the desirable result for
some test cases due to logical errors. Your task is to fix the code so that it passes all the test cases.
---------------------------------------
Testcase 1:
Input:
4,[4,2,8,6]
6824
Testcase 2:
Input:
3,[11,20,17]
17 20 11
---------------------------------------
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
void arrayReverse(int len,int *arr)
int i,temp,originalLen=len;
for(i=0;i<=originalLen/2;i++)
temp=arr[len-1];
arr[len-1]=arr[i];
arr[i]=temp;
len-=1;
---------------------------------------
Problem (3 ):
The function/method printCharacterPattern accepts an integer num. It is supposed to print the first
num(0<=num<=26) lines of the pattern as shown below:
ab
abc
abcd
The function/method printCharacterPattern compiles successfully but fails to get desirable output. Fix
the logical errors.
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
int i,j;
char ch='a';
char print;
for(i=0;i<num;i++)
print=ch;
for(j=0;j<=i;j++)
printf("%c",ch++);
printf("\n");
-------------------------------------------
Solution:
int i,j;
char ch='a';
char print;
for(i=0;i<num;i++)
print=ch;
for(j=0;j<=i;j++)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
printf("%c",print++);
printf("\n");
-------------------------------------------
Probelm ( 4 ):
The function/method removeElement prints space seperated integer that remains after removing the
integer at the given index from the input list.
The function/method removeElement accepts three arguments,size an integer representing the sizeof
input list, indexValue an integer representing given index and inputList, a list of integers representing
the input list.
The function/method removeElement compiles code successfully but fails to get the desirable result for
some test cases due to incorrect implementation of function/method removeElement. Your task is to fix
the code so that it passes all the test cases.
---------------------------------------
Test case 1:
Status: wrong
Expected:
12356789
Returned
12344668
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
Test case 1:
Status: correct
Expected:
11 23 12 34 54 32
Returned
11 23 12 34 54 32
---------------------------------------
int i,j;
if(indexValue<size)
for(i=indexValue;i<size;i++)
inputList[i]=inputList[i++];
for(i=0;i<size-1;i++)
printf("%d",inputList[i]);
else
for(i=0;i<size;i++)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
printf("%d",inputList[i]);
-------------------------------------------
solution:
int i,j;
if(indexValue<size)
for(i=indexValue;i<size;i++)
inputList[i]=inputList[i+1];//1 2 3 4 5 6 7 8 9
for(i=0;i<size-1;i++)
printf("%d",inputList[i]);
else
for(i=0;i<size;i++)
printf("%d",inputList[i]);
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
-------------------------------------------
Probelm ( 5 ):
The function calculateMatrixSum(int ** matrix, int m, int n) accepts a two dimensional array matrix of
dimensions m, n as input and returns the sum of odd elements whose ith and jth index are same.
The function compiles successfully but fails to return the desired result for some test cases
PROGRAM
int i,j,sum=0;
if((row>0)&&(column>0))
for(i=0;i<row;i++)
sum=0;
for(j=0;j<column;j++)
if(i==j)
if(matrix[i][j]/2!=0)
sum+=matrix[i][j];
return sum;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
else
return sum;
-------------------------------------------
solution:
int i,j,sum=0;
if((row>0)&&(column>0))
for(i=0;i<row;i++)
for(j=0;j<column;j++)
if(i==j)
if(matrix[i][j]%2!=0)
sum+=matrix[i][j];
return sum;
else
return sum;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
Problem (6):
The function/method sortArray modify the input list by sorting its elements in descending order. It
accepts two arguments-len,representing the length of the list and arr, a list of integers representing the
input list respectively.
It compiles successfully but fails for some test case. Fix the code..
-------------------------------------------
int i,max,location,j,temp;
for(i=0;i<len;i++)
max=arr[i];
location=i;
for(j=i;j<len;j++)
if(max>arr[j])
max=arr[j];
location=j;
temp=arr[i];
arr[i]=arr[location];
arr[location]=temp;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
solution:
int i,max,location,j,temp;
for(i=0;i<len;i++)
max=arr[i];
location=i;
for(j=i;j<len;j++)
if(max<arr[j])
max=arr[j];
location=j;
temp=arr[i];
arr[i]=arr[location];
arr[location]=temp;
for(i=0;i<len;i++)
printf("%d ",arr[i]);
------------------------------------------
Problem ( 7 ):
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
The function/method replaceValues is modifying the input list in such a way - if the length of the input
list is odd, then all the elements of the input list are supposed to be replaced by 1s and in case it is even,
the elments should be replaced by 0s.
For example, given the input list[0,1,2], the function will modify the input list like [1 1 1].It accepts two
arguments size, an integer representing the size of input listand inputlist , a list of integers.
The function complies successfully but fails to return the desired results due to logical errors
Your task is to debug the program to pass all the test cases
-------------------------------------------
int i,j;
if(size%2==0)
i=0;
while(i<size)
inputList[i]=0;
i+=2;
else
j=0;
while(j<size)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
inputList[j]=1;
j+=2;
-------------------------------------------
solution:
int i,j;
if(size%2==0)
i=0;
while(i<size)
inputList[i]=0;
i+=1;
else
j=0;
while(j<size)
inputList[j]=1;
j+=1;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
-------------------------------------------
Problem ( 8 ):
The function productMatrix accepts a two dimensional array matrix of dimensions m, n as input and
returns the sum of odd elements whose ith and jth index are same.
The function compiles line but fails to return the desired result for some test cases
PROGRAM
int result=0;
for(i=0;i<row;i++)
for(j=0;j<column;j++)
if((i==j)||matrix[i][j]%2!=0)
result*=matrix[i][j];
if(result<=1) return 0;
else
return result;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
solution:
int result=0,flag=0;
for(i=0;i<row;i++)
for(j=0;j<column;j++)
result*=matrix[i][j];
flag=1;
if(flag==0)
return 0;
else
return result;
----------------------------------------------------------------
Problem ( 9 ):
The function maxReplace is supposed to replace every element of the input array arr with the maximum
element of arr.
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
Your task is to debug the program to pass all the test cases
PROGRAM:
int i;
if(size>0)
int max=inputList[0];
for(i=0;i<size;i++)
if(max<inputList[i])
max=inputList[i]; }
for(i=0;i<size,i++)
inputList[i]=max
printf("%d",inputList[i]);
-------------------------------------------
solution:
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
int i,max;
if(size>0)
max=inputList[0];
for(i=0;i<size;i++)
if(max<inputList[i])
max=inputList[i]; }
for(i=0;i<size;i++)
inputList[i]=max;
printf("%d",inputList[i]);
-------------------------------------------
Problem ( 10 ):
The function/method sumElement return an integer representing the sum of the elements in the input
array that are greater than twice the input number K and present at the even index. It accepts three
aguments-size of array, numK representing input number and inputarray list of integers.
-------------------------------------------
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
int i,sum=0;
for(i=0;i<size;i++)
sum=inputArray[i];
return sum;
-------------------------------------------
solution:
int i,sum=0;
for(i=0;i<size;i++)
sum+=inputArray[i];
return sum;
-------------------------------------------
Problem (11):
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
The function/method manchester: for each element in the input array arr, a counter is incremented if
the bit arr[i] is same as arr[i-1]. Then the increment counter value is added to the output array to store
the result.
If the bit arr[i] and arr[i-1] are different, then 0 is added to output array. for the first bit in the input
array, assume its previous bit to be 0. For example if arr is {0,1,0,0,1,1,1,0}, then it should print 1 0 0 2 0
3 4 0.
It accepts two arguments-size and arr-list of integers. Each element represents a bit 0 or 1.
It compiles successfully but fails to print the desirable result. Fix the code.
bool result;
int count=0;
for(int i=0;i<size;i++)
if(i==0)
result=(arr[i]==0);
else
result=(arr[i]==arr[i-1]);
res[i]=(result)?0:(++count);
for(int i=0;i<size;i++)
printf("%d",res[i]);
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
solution:
bool result;
int res[size];
int count=0;
for(int i=0;i<size;i++)
if(i==0)
result=(arr[i]==1);
else
result=!(arr[i]==arr[i-1]);
res[i]=(result)?0:(++count);
for(int i=0;i<size;i++)
printf("%d ",res[i]);
-------------------------------------------
Problem (12):
For example,given input 5, the function should print the string "01123"(without quotes).
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
It compiles successfully but fails to give the desirable result for some test cases. Debug the code.
-------------------------------------------
long num1=0;
long num2=1;
for(int i=1;i<num;++i)
printf("%ld",num1);
long sum=num1+num2;
num2=sum;
num1=num2;
-------------------------------------------
Solution:
long num1=0;
long num2=1;
for(int i=1;i<=num;++i)
printf("%ld ",num1);
long sum=num1+num2;
num1=num2;
num2=sum;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
-------------------------------------------
Problem (13):
The function/method selectionSortArray performs an in-place selection sort on the given input list which
will be sorted in ascending order.
It accepts two arguments-len,an integer representing the length of input list and arr, alist of integers
representing the input list respectively.
-------------------------------------------
int x=0,y=0;
for(x=0;x<len;x++)
int index_of_min=x;
for(y=x;y<len;y++)
if(arr[index_of_min]>arr[x]){
index_of_min=y;
int temp=arr[x];
arr[x]=arr[index_of_min];
arr[index_of_min]=temp;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
-------------------------------------------
solution:
int x=0,y=0;
for(x=0;x<len;x++)
int index_of_min=x;
for(y=x;y<len;y++)
if(arr[index_of_min]>arr[y]){
index_of_min=y;
int temp=arr[x];
arr[x]=arr[index_of_min];
arr[index_of_min]=temp;
for(x=0;x<len;x++)
printf("%d ",arr[x]);
------------------------------------------
Probelm (14):
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
The function/method descendingSortArray performs an in-place sort on the given input list which will be
sorted in descending order.
-------------------------------------------
for(i=0;i<=len-1;i++)
for(j=i;j<len;j++)
temp=0;
if(arr[i]>arr[j])
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
-------------------------------------------
solution:
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
void descendingSortArray(int len, int *arr)
for(i=0;i<=len-1;i++)
for(j=i+1;j<len;j++)
temp=0;
if(arr[i]<arr[j])
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
for(i=0;i<=len-1;i++)
printf("%d ",arr[i]);
-------------------------------------------
problem (15):
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
11
111
1111
-------------------------------------------
int print=1,i,j;
for(i=0;i<num;i++)
for(j=0;j<=i;j++);
printf("%d", print);
printf("\n");
-------------------------------------------
solution:
int print=1,i,j;
for(i=0;i<num;i++)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
for(j=0;j<=i;j++)
printf("%d", print);
printf("\n");
-------------------------------------------
Problem (16):
Lisa always forgets her birthday which is on the 5th of july. So,develop a function/method which will be
helpful to remember her birthday.
It return an integer "1" if it is her birthday else return 0. It accepts two argument-month of her birthday,
day of her birthday.
-------------------------------------------
if(strcmp(month,"July"))||(day==5))
return 1;
else
return 0;
-------------------------------------------
solution:
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
if(strcmp(month,"July"))&&(day==5))
return 1;
else
return 0;
-------------------------------------------
Problem (17):
-------------------------------------------
int i,count=0;
for(i=0;i<size;i++)
if((inputList[i]%2==0)&&(inputList[i]==inputList[i++])
count++;
return count;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
-------------------------------------------
solution:
int i,count=0;
for(i=0;i<size-1;i++)
count++;
return count;
-------------------------------------------
Problem (18):
The function/method manchester: for each element in the input array arr, a counter is incremented if
the bit arr[i] is same as arr[i-1]. Then the element of the list is 0, otherwise 1.
for the first bit in the input array, assume its previous bit to be 0. For example if arr is {0,1,0,0,1,1,1,0},
then it should print {0,1,1,0,1,0,0,1}
It accepts two arguments-size and arr-list of integers. Each element represents a bit 0 or 1.
It compiles successfully but fails to print the desirable result. Fix the code.
-------------------------------------------
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
void manchester(int len,int *arr)
int res[len];
res[0]=arr[0];
for(int i=1;i<len;i++)
res[i]=(arr[i]==arr[i-1]);
for(int i=0;i<len;i++)
printf("%d",res[i]);
-------------------------------------------
solution:
int res[len];
res[0]=arr[0];
for(int i=1;i<len;i++)
res[i]=!(arr[i]==arr[i-1]);
for(int i=0;i<len;i++)
printf("%d",res[i]);
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
-------------------------------------------
problem (19):
11
1111
111111
11111111
-------------------------------------------
int i,j,print=1;
for(i=1;i<=num;i++)
for(j=1;j<=2*i;j++);
printf("%d",print);
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
printf("\n");
-------------------------------------------solution:
int i,j,print=1;
for(i=1;i<=num;i++)
for(j=1;j<=2*i;j++)
printf("%d",print);
printf("\n");
-------------------------------------------
Problem (20):
The function/method countOccurence return integer representing the count of occurence of given value
in input list.
-------------------------------------------
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
int i=0,count=0;
while(i<len)
if(arr[i]==value)
count+=1;
return count;
-------------------------------------------solution:
int i=0,count=0;
while(i<len)
if(arr[i]==value)
count+=1;
i++;
return count;
-------------------------------------------
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
Problem (21):
You are given predefined structure Time containing hour,minute and second as members. A collection of
functions/methods for performing some common operations on times is also available. You must use
these functions/methods to calculate and return the difference.
It accepts two arguments time1 and time 2 representing two times and is supposed to return an integer
represents the difference in the number of seconds.
You must complete the code so that it passes all the test cases.
Note:
The following structure is used to represent the time and is already implemented in the default code.
typedef struct
int hour,
int minute,
int second;
}Time;
/* Return 1, if time1>time2
Return -1 if time1<time2
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
This can be called as
*Time_compareTo(time1,time2);*/
---------------------------------------
//write code
-----------------------------------------
solution:
#include<stdio.h>
typedef struct
int hour;
int minute;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
int second;
}Time;
int difference_in_times(Time*,Time*);
int t1s,t2s;
int main()
Time t1,t2;
t1.hour=11;t1.minute=43;t1.second=50;
t2.hour=9;t2.minute=27;t2.second=57;
t1s=t1.hour*60*60+t1.minute*60+t1.second;
t2s=t2.hour*60*60+t2.minute*60+t2.second;
if(t1s>t2s) return 1;
return 0;
return 0;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
Problem (22):
The function findMaxElement(int *arr1,int len1,int *arr2,int len2) accepts twointeger arrays arr1,arr2 of
length len1,len2 respectively.It is supposed to return the largest element in both the input arrays.
Another function sortArray(int *arr,int len) sorts the input array arr of length lenin ascending order and
returns the sorted array.
Your task is to use sortArray(int *arr,int len) function and complete the codein findMaxElement(int
*arr1,int len1,int *arr2,int len2) so that it passes all testcases"
---------------------------------------
int i=0,j=0,temp=0;
for(i=0;i<len;i++)
for(j=i+1;j<len;j++)
if(arr[i]>arr[j])
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
return arr;
-------------------------------------------
Solution:
int i=0,j=0,temp=0;
for(i=0;i<len;i++)
for(j=i+1;j<len;j++)
if(arr[i]>arr[j])
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
return arr;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
int findMaxElement(int len1,int *arr1,int len2,int *arr2)
if(sort_array1[len1-1]>sort_array2[len2-1])
printf("%d",sort_array1[len1-1]);
else
printf("%d",sort_array2[len2-1]);
-------------------------------------------
Problem (23):
The function allExponent(int base,int exponent)accepts two integers base and exponent as inputs.it is
supposed to calculate and return of exponentation of base raised to power exponent for all input values.
The function positiveExponent(int base,int exponent) will return the exponentiation value if exponent
value is positive. try to complete the code such that allExponent should return value if exponent value is
negative
PROGRAM
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
float res=1;
if(exponent >=0)
Res = (float)positiveExponent(base,exponent)
Else
return res;
-------------------------------------------
solution:
float res=1;
if(exponent >=0)
res = (float)positiveExponent(base,exponent);
else
res = 1/((float)positiveExponent(base,-(exponent)));
return res;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
int sol=pow(base,exponent);
return sol;
-------------------------------------------
Problem (24):
The function/method isTriangle which accepts three points P1,P2,P3 as inputs and checks whether the
given three points form a triangle.
int X;
int Y;
}Point;
-------------------------------------------
//write code
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
------------------------------------------
solution:
int a=P1.X*(P2.Y-P3.Y)+P2.X*(P3.Y-P1.Y)+P3.X*(P1.Y-P2.Y);
if(a==0)
return 0;
else
return 1;
----------------------------------------
Problem (25):
Charlie has a magic mirror. The mirror shows right rotated versions of a given word.
To generate different right-rotations of a word, write the word in a circle in clockwise order,
then start reading from any given character in clockwise order till you have covered all the characters.
For example: In the word "sample", if we start with 'p', we get the right rotated word as
"plesam". There are six such right rotations of "sample" including itself.
The inputs to the function isSameReflection consists of two strings, word1 and word2.
The function returns 1 if word1 and word2 are right rotations of the same word and -1 if they are not.
Both word 1 and word2 will strictly contain characters between 'a'-'z' (lower case letters).
-->Useful commands:
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
strlen() is used to calculate the length of the string.
---------------------------------------
int size1=strlen(word1);
int size2=strlen(word2);
char *temp;
void *ptr;
if(size1!=size2)
return -1;
temp[0]='';
//temp=samplesample word2=zlesam
ptr=strstr(temp,word2);//word2 is there in temp and return index of first char of word2 in temp,
if word2 is not a substring it will return null.
if(ptr!=null)
return 1;
else
return -1;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
----c++-----
if(str1.length()!=str2.length())
return false;
string temp=str1+str1;
if(temp.find(str2)!=string::npos))
return 1;
-------------------------------------------
Problem (26):
The function/method isRightTriangle which accepts three points P1,P2,P3 as inputs and checks whether
the given three points form a right angled triangle.
int X;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
int Y;
}Point;
------------------------------------------
solution:
double d1,d2,d3;
d1=Point_calculateDistance(P1,P2);
d2=Point_calculateDistance(P2,P3);
d3=Point_calculateDistance(P3,P1);
if(pow(d1,2)+pow(d2,2)==pow(d3,2)||
pow(d2,2)+pow(d3,2)==pow(d1,2)||
pow(d3,2)+pow(d1,2)==pow(d2,2))
return 1;
else
return 0;
-------------------------------------------
Problem (27):
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
The function/method median accepts two arguments-size and inputList,an integer representing the
length of a list and a list of integers respectively.
It is supposed to calculate and return an integer representing the median of elements in the input list.
However the function/method median works only for odd-length lists because of incomplete code.
-------------------------------------------
solution:
int start_index=0;
int end_index=size-1;
float res=-1;
if(size%2!=0)
int med_1=size/2;
int med_2=(size/2)+1;
res=((float)quick_select(inputList,start_index,end_index,med_1));
else
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
res=((float)quick_select(inputList,start_index,end_index,med_1)+(float)quick_select(inputList,st
art_index,end_index,med_2))/2;
return res;
-------------------------------------------
Compilation error:
Problem (28):
The function/method matrixSum returns an integer representing the sum of elements of the input
matrix.
The function/method matrixSum accepts three arguments- rows, an integer representing the number of
rows ,columns an integer representing number of columns, matrix is going to be the input matrix.
The function/method matrixSum has some compilation error. Rectify the error and get the desired
output:
-------------------------------------------
int i,j,sum=0;
for(i=0;i<rows;i++)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
for(j=0;j<columns;j++)
sum+=matrix(i)(j);
return sum;
-------------------------------------------
solution:
int i,j,sum=0;
for(i=0;i<rows;i++)
for(j=0;j<columns;j++)
sum+=matrix[i][j];
return sum;
-------------------------------------------
Problem (29):
The function/method countElement return an integer representing the number of elements in the input
list which are greater than twice the input number K.
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
The function/method accepts three arguments-size, an integer representing the size of input list, numK
an integer representing the input number K and inputList, a list of integers representing the input list,
respectively.
The function/method countElement compiles unsuccessfully due to systematical error. Fix the code so
that it passes all test cases.
----------------------------------------
int i,co-unt=0;
for(i=0;i<size;i++)
if(inputList[i]>2numK)
co-unt+=1;
return co-unt;
-----------------------------------------
solution:
int i,count=0;
for(i=0;i<size;i++)
if(inputList[i]>2*numK)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
count+=1;
return count;
-------------------------------------------
Problem (30):
The function/method deleteNonRepeat accpets two arguments-size, an integer representing the size of
the list and inputList,representing the list of integers.
It removes the non-repeated integres from the inputList and prints the remaining repeated integers
seperated by space from inputList.
If all the elements are unique then the function should not print anything.
-------------------------------------------
int count=0,i,j;
int counter[size];
for(i=0;i<size;i++)
counter[i]=1;
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
}
for(i=0;i<size;i++)
for(j=i+1;j<size;j++)
if(inputList[i]==inputList[j])
counter[i]++;
counter[j]++;
for(i=0;i<size;i++)
if(counter[i]>1)
count++;
j=0;
for(i=0;i<size;i++)
if(counter[i]>1)
printf("%d",inputList[]);
-------------------------------------------
solution:
int count=0,i,j;
int counter[size];
for(i=0;i<size;i++)
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
{
counter[i]=1;
for(i=0;i<size;i++)
for(j=i+1;j<size;j++)
if(inputList[i]==inputList[j])
counter[i]++;
counter[j]++;
for(i=0;i<size;i++)
if(counter[i]>1)
count++;
j=0;
for(i=0;i<size;i++)
if(counter[i]>1)
printf("%d",inputList[i]);
-------------------------------------------
Problem (31):
The function/method multiplyNumber returns an integer representing the multiplicative product of the
maximum two of three numbers. It accepts three integers- numA,numB,and NumC,representing the
input numbers.
Telegram: https://t.me/campusdrive
Telegram: https://t.me/campusdrive
-------------------------------------------
int result,min,max,mid;
max=(numA>numB)?numA>numC)?numA:numc):((numB>numC)?numB:numC);
min=(numA<numB)?((numA<numC)?numA:numc):((numB<numC)?numB:numC);
mid=(numA+numB+numC)-(min+max);
result=(max*int mid);
return result;
-------------------------------------------
solution:
int result,min,max,mid;
max=(numA>numB)?((numA>numC)?numA:numc):((numB>numC)?numB:numC);
min=(numA<numB)?((numA<numC)?numA:numc):((numB<numC)?numB:numC);
mid=(numA+numB+numC)-(min+max);
result=(max* mid);
return result;
-------------------------------------------
Telegram: https://t.me/campusdrive
He who has never learned to obey cannot be a good leader'' Write a response that describes the
traits of a good leader. To what extent do you agree with your statement? Explore the arguments
for and against the statement. Max words 400
First of all, confidence is the best quality. A leader must have strong self-confidence. A person
lacking in confidence can never be a good leader. A person must be confident enough to ensure
others follow him. The leader must have confidence in his decisions and actions. If he is unsure,
then how can people have the desire to follow him?
A good leader must certainly inspire others. A leader must be a role model for his followers.
Furthermore, he must motivate them whenever possible. Also, in difficult situations, a leader
must not lose hope. How can a leader inspire people if he himself is hopeless?
Honesty is another notable quality of a leader. Honesty and Integrity are important to earn the
love of followers. Above all, honesty is essential to win the trust of the people. Probably, every
Leadership which loses trust is bound to fail. People will not work with full effort due to an
immoral leader.
Good communication is a must for a good leader. This is because poor communication means the
wrong message to followers. Furthermore, good communication will increase the rate of work.
Also, the chances of mistakes by followers will be reduced.
Another important quality is decision making. Above all, if a leader makes poor decisions then
other qualities will not matter. Furthermore, good decision making ensures the success of the
entire group. If the leader makes poor decisions, then the efforts of followers won’t matter.
A good leader must be an excellent innovator. He must display a creative attitude in his work.
Most noteworthy, innovation is a guarantee of survival of a group or innovation. Without creative
thinking, progress is not possible.
The gap between the rich and the poor has moved to the extreme ends over the last decade. The
rich have continued to gain more wealth and grow richer whilst the poor have remained poor.
The gap between rich and poor depicts the inequality in income distribution between the rich and
the poor.
There are various reasons for the increasing gap between the rich and the poor in society. In most
cases, these reasons are related. Research study on the gap between the rich and the poor affirms
that; culture, innate capability, globalization, education, labor markets, reforms on taxes,
government policies, change in technology, gender, racism and differences in wages and incomes
as the main causes.
The difference in wages and salaries is the core reason for the growing gap between the rich and
the poor. The job salaries are indomitable by the supply and demand in the commercial market.
For instance, when the supply of labor is high and demand for working force is low, the wages
for the few available job opportunities will be as well low
Besides the market related factors that affect the differences in wages, initiatives facilitated by
the government such as tax reforms and policies can also result in an increase or decrease in
inequality. Social scientists and policy developers argue on the efficiency and effectiveness of the
inequality regulations strategies. Some of the governmental distinctive initiatives which can
minimize the difference between the rich and the poor involve; educating the public that
enhances the skills of the workforce supply in order to minimize the wage difference related to
education factors.
The implementation of tax reforms programs which will impose relatively higher taxes on the
rich compared to the unfortunate will be very significant in regulating income differences within
the society. Establishment of minimum income legislative initiative will assist in enhancing
wages for the unfortunate laborers. An initiative to subsidize product prices will enable
consumers to purchase goods and services at relatively low prices. These initiatives will prove to
be very vital in reducing the gap between the rich and the poor within the society.
In general, the situation in which only the rich continue to be rich can be reduced if not solved
through emphasizing more on education, investing in human capital and economic literacy. The
problem has been there for ages and the gap seems to widen by the dawn of each new day.
#include<bits/stdc++.h>
// check condition
return false;
else
return true;
// Driver function
int main()
int a = 7, b = 10, c = 5;
if (checkValidity(a, b, c))
cout << "Valid";
else
Technology is everywhere and around us. The thing that you put in your pocket while travelling,
your mobile phone is the most prime example of technology. GPS navigation, computer, internet,
fan, A/C, and every other device we use in our daily lives are also prime examples of technology.
Without technology, life would be dull and hard. Nowadays, countries that have more advanced
technologies are developing day by day.
It is observed in a survey that people can’t live without technology even a single day as they
survive on cell phones. People get so addicted to technological devices that they are not able to
work without them. Many companies and industries are dependent on these technologies to
operate their functions and manufacture goods.
People are so addicted that they prefer to use their mobile phones to communicate rather than
communicating face to face. This affects their mental health and also their relationship with
friends and family. People spend lots of money on buying new technology as they have advanced
and better features.
The Internet is the prime cause of addiction to mobile phones and computers. It was introduced
as a medium to help people for searching for information and data but people started misusing
the internet which results in addiction. People started spending hours and hours on mobile
phones surfing the internet and watching online videos. Nowadays even children have to wear
glasses because of weak eyesight due to continuously using mobile phones and computers.
A librarian has to rearrange the library books on a shelf in a proper order at the end of each day.
Which of the following sorting techniques should be the librarian's ideal choice?
Insertion Sort
A sorting algorithm traverses through a list, comparing adjacent elements and switching them
under certain conditions.
Bubble sort
A programmer tries to debug a code of 10,000 lines. It is known that there is a logical error in the
first 25 lines of the code. What is an efficient way to debug the code?
The tight curriculum of our current education system leaves no room for imagination and
creativity-essay
I whole heartedly agree that the tight curriculum of our current education system leaves no room
for imagination and creativity. The academic pressure is so much on them, they have forgotten
their innate creativity and imagination. They are always under the pressure of studies. This
pressure is put on them from the beginning of the session. Formative assessment activities of all
the subjects, studies and their assignments of all the subjects, unit tests, co-curricular activities,
homework, classwork, projects, practical exams, summative examination, date sheet, result,
again the new term, etc. So much of pressure on the young growing children! Are we educating
them or training them the art of being stressful throughout their childhood?
Even while studying inside class, they feel so burdened; they have come to dislike education. as
a result there is hardly any creativity left in our country. Every year all the illustrious prizes for
creativity are won by non-Indians or Indians living in advanced countries. Our educationists
must rethink and revise the curriculum to encourage creativity and imagination in children --- not
rot learning.
With each passing day, education is becoming more difficult and the system is getting stricter.
With such heavy rules and regulations in academics, students hardly have the opportunity to
dream and imagine. Children are known for their imagination and it is due to imagination that
they can explore new creative arenas. This is creating individuals who are extremely methodical
but the true meaning of education is somewhat missing. Education teaches us to be more vocal
about our likings and disliking and improves our imaginative skill and creativity.
Unfortunately the Indian education system changed so drastically that the talent of students is
being measured only based on the marks scored by him and the success of the educational
system is being measured by the number of students who scored a centum. If the student couldn't
perform well in the exams, he is tagged ‘Average student’ which is looked at as a disgrace for
both the student and the parents. Hence students are very busy in the rat race to score marks and
ranks and are not in a position to realize the main purpose of education i.e. to learn new things.
School is not just a place where you learn a few subjects, pass the examinations and move out. It
is a place where the foundation for the rest of the life like the moral values, behavior in the
society and creativity are laid for tomorrow’s generation. But the present education hardly
concentrates on these issues. There are very few schools where moral science and personality
development counseling are part of their curriculum. There are very few schools with a proper
school ground and art room, aside from the importance given to the extracurricular activities.
1)Furniture
2)plant
3)seed
1)PSQR
2)SVTU
3)MPON
4)DGEF
Ans: MPON
Insufficient data. All the statements put together are not sufficient.
3 7 13 21 ? Ans: 31
GIVE people power and discretion, and whether they are grand viziers or border guards, some
will use their position to enrich themselves. The problem can be big enough to hold back a
country's development. One study has shown that bribes account for 8% of the total cost of
running a business in Uganda. Another found that corruption boosted the price of hospital
supplies in Buenos Aires by 15%. Paul Wolfowitz, the head of the World Bank, is devoting
special efforts during his presidency there to a drive against corruption.
For most people in the world, though, the worry is not that corruption may slow down their
country's GDP growth. It is that their daily lives are pervaded by endless hassles, big and small.
And for all the evidence that some cultures suffer endemic corruption while others are relatively
clean, attitudes towards corruption, and even the language describing bribery, is remarkably
similar around the world.
In a testament to most people's basic decency, bribe-takers and bribe-payers have developed an
elaborate theatre of dissimulation. This is not just to avoid detection. Even in countries where
corruption is so common as to be unremarkable and unprosecutable—and even when the
transaction happens far from snooping eyes—a bribe is almost always dressed up as some other
kind of exchange. Though most of the world is plagued by corruption, even serial offenders try
to conceal it.
Related items
One manifestation of this is linguistic. Surprisingly few people say: “You are going to have to
pay me if you want to get that done.” Instead, they use a wide variety of euphemisms. One type
is quasi-official terminology. The first bribe paid by your correspondent, in Ukraine in 1998,
went to two policemen so they would let him board a train leaving the country. On the train into
Ukraine, the customs officer had absconded with a form that is needed again later to leave the
country. The policemen at the station kindly explained that there was a shtraf, a “fine” that could
be paid instead of producing the document. The policemen let him off with the minimum shtraf
of 50 hryvnia ($25).
Another term widely used at border crossings is “expediting fee”. For a euphemism it is
surprisingly accurate: paying it will keep your bags, and perhaps your contraband, from being
dumped onto a floor and sifted through at a leisurely pace. (A related term, used in India, is
“speed money”: paying it can get essential business permits issued considerably faster.)
Paul Lewis, an analyst with the Economist Intelligence Unit (a sister company to The
Economist), describes the quasi-business terminology typically used for bribery in the
post-communist privatisations of eastern Europe. A mostly useless but well-connected insider at
the company is hired as a “consultant”. The consultant is paid a large official “fee”, nominally
for his industry expertise, on the understanding that he will cut in the minister and other
decision-makers.
A second type of euphemism dresses up a dodgy payment as a friendly favour done by the
bribe-payer. There is plenty of creative scope. Nigerian policemen are known to ask for “a little
something for the weekend”. A North African term is “un petit cadeau”, a little gift. Mexican
traffic police will suggest that you buy them a refresco, a soft drink, as will Angolan and
Mozambican petty officials, who call it a gazoso in Portuguese. A businessman in Iraq told
Reuters that although corruption there is quite overt, officials still insist on being given a “good
coffee”.
Double meaning can help soothe the awkwardness of bribe-paying. Baksheesh, originally a
Persian word now found in many countries of the Middle East, can mean “tip”, “alms” and
“bribe”. Swahili-speakers can take advantage of another ambiguous term. In Kenya a
machine-gun-wielding guard suggested to a terrified Canadian aid worker: “Perhaps you would
like to discuss this over tea?” The young Canadian was relieved: the difficulty could be resolved
with some chai, which means both “tea” and “bribe”.
India lives in several centuries at the same time. Somehow we manage to progress
like the maturing head of a hammerhead shark with eyes looking in diametrically
opposite directions.
I don’t mean to put a simplistic value judgment on this peculiar form of “progress” by
suggesting that Modern is Good and Traditional is Bad–or vice versa. What’s hard
to reconcile oneself to, both personally and politically, is the schizophrenic nature of
it. That applies not just to the ancient/modern conundrum but to the utter illogic of
what appears to be the current national enterprise. In the lane behind my house,
every night I walk past road gangs of emaciated laborers digging a trench to lay
fiber-optic cables to speed up our digital revolution. In the bitter winter cold, they
It’s as though the people of India have been rounded up and loaded onto two
convoys of trucks (a huge big one and a tiny little one) that have set off resolutely in
somewhere near the top of the world. The other convoy just melts into the darkness
and disappears. A cursory survey that tallies the caste, class and religion of who
gets to be on which convoy would make a good Lazy Person’s concise Guide to t
Questions
2. What do you infer from the sentence -'For some of us, life in …...but emotionally and
intellectually'?
a. A person has one leg in one truck and the other in the second truck.
4. What does the sentence "We greaten like the maturing head of a hammerhead shark with
eyes looking in diametrically opposite directions.' implies?
5. What do you infer from the sentence in context of the passage-'India lives in several
centuries at the same time.'?
d. Some people are modern while the others are traditional in approach.
6. What do you infer from the following lines-'In the lane behind my house, every night I
walk past road gangs of emaciated labourers digging a trench to lay fiber-optic cables to speed
up our digital revolution? In the bitter winter cold, they work by the light of a few candles.’?
b. Progress is unbalanced.
a. People from one culture do not respect people from the other cultures.
8. Why does the response towards 'Globalisation in India' differs in different parts of India?
Which expression gives maximum number of nodes at level I of binary tree (the root is at level I)
Ans: 2^1 – 1
Identify the Lowest level format to which computer converts a higher language program before
execution
Ans: Compiler
A programmer is making a database of animals in zoo along with their properties possible
animals dog lion and zebra is attributes herbivorous colour and not eternal the programmer is an
object oriented programming faradism for this how is the system by conceptualized
The system must be designed in the following way - class: Animal; objects: dog, lion and zebra;
data members: is Herbivorous, colour and is Nocturnal. The Object Oriented Programming is
referred as the model of programming language that is organised around the objects rather than
the "actions" and data than the logic. A program is generally viewed as the logical procedure
which takes the input data and produces output after processing it.
sorting algorithm iteratively traverses through a list to exchange the first element with any
element less than it. It then
repeats with a new first element. What is this sorting algorithm called?
X and Y are asked to write a program to sum the rows of a 2x2 matrix stored in an array A.
for n = 0 to 1
end
Which of the following statements is correct about these codes if no loop unrolling is done by the
compiler?
A language has 28 different letters in total. each word in the language is composed of maximum
7 letters. you want to create a data-type to store a word of this language. you decide to store the
word as an array of letters. how many bits will you assign to the data-type to be able to store all
kinds of words of the language.
Ans: 35 bits
#include <stdio.h>
#include <stdlib.h>
int main(void)
int *a,n,i,j,temp;
scanf("%d",&n);
a=malloc(sizeof(int)*n);
printf("Enter %d Elements:",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=n/2,j=n-1;i<j;i++,j--)
temp=a[i];
a[i]=a[j];
a[j]=temp;
for(i=0;i<n;i++)
printf("%d ",a[i]);
return 0;
Ans: Deletion
The current situation (where workers have to look after their children as well as work/earn) leads
to a situation called work-family conflict. It refers to pressures from work and family domains,
which are incompatible with each other in such a way that meeting requirements of one role
makes it difficult to satisfactorily fulfill the other role. According to research, working long
hours is one of the sources of work-family conflict. Hence, to maintain the balance between
work and family life, the theory “work-life balance” has been adopted. According to which the
growth of any company depends on the interrelated performance and commitment of the
employees. Both personal and professional lives are interrelated and difficult to be separated
from each other. Organization needs to keep its employees happy and satisfied to get the
maximum productivity . The balance is achieved when an individual’s rights are fulfilled by the
people from whom he/she is expecting to sort out the core problems and issues regarding
professional and personal life. Previous studies elaborates that employees satisfaction,
motivation, profitability, productivity, recruitment and retention policies can be improved by
adopting flexible working arrangements and full determination towards the betterment of the
employees and organizational goals.
Today, the work life balance is a common issue at every workplace. The work life balance
creates balance between the work and life includes career and the life style. It is the state of
equilibrium where any person is able to get satisfies with personal and professional life.
Balancing time with parents, spouse, children, friends, relatives, colleagues, supervisors and
subordinates is the biggest challenge to be achieved. The empirical study gives the idea of work
life balance performed in past. Work life balance has become a challenge throughout the world.
The study will identify the assessment of employees about their organization from the work life
balance prospective and how it is practiced at their workplace. This will also measure the level of
job satisfaction of employees of the PIA in relation to their socio-economic factors. It is to be
cited from , the individuals are facing the challenges that how they balance their work life and
personal life. It is to be cited from that this study is also supported by (lewis et al, 2012) who
study younger’s in four European countries and found the positive desire related to work life
balance.Without balance in working life and personal life, it is very difficult to maintain and
control the personal and working life. In order to be satisfied, the individual must create the
balance between their work life and personal life. It is found generally that work life balance is
too difficult.
We want to become technically___interns of technological results
Ans: recognized
The monk wanders here and there in search of silence and peace his lives a ____ life
Ans: Simple/peaceful
A. Always has
B. Always had
C.always have
D. No improvement needed
24:50::102: Ans: 206
Which of the following sorting algorithms yield approximately the same worst-case
Which of the following statement is not true about breadth -first search (BFS) in an undirected
graph starting at a vertex v?
b. using an adjancey list instead of anadjancey matrix can improve the wrost case complexity to
on (n+m).
d. BFS can be used to identify the furthest vertex from V in any graph.
Ans: 1-->true 2-->false 3-->false 4-->true
Space complexity is a measure of the amount of working storage an algorithm needs. That means
how much memory, in the worst case, is needed at any point in the algorithm. As with time
complexity, we're mostly concerned with how the space needs to grow, in big-Oh terms, as the
size N of the input problem grows.
First of all, there is a lot of environmental pollution in a big city and they cause illnesses such as
asthma. People who are in small-town expose less to these problems because generally there
aren't factories, many cars and big construction in there. Also, a small town has many green
places. People know now that their life is valuable and they should spend it well. They want to
live a quality life outside of stress or some health problem. According to research, people who
live in a green place have a longer life than other people.
Furthermore, there are many kinds of products in a big city but generally, they are expensive
because when these products arrive there, fuel oil money and employees' salary add to their cost.
For that, vegetables and fruits cost very high in a big city. These events don't exist in a small
town because they produce their vegetables and fruits. They can consume them or sell them in a
villager bazaar. Also, house rent is very high especially if it is close to the city center. On the
other hand, there is no problem with the small town because the population is low and there isn't
rivalry there for that reason many people prefer a small town.
To summarize, people who want a calm, healthy and cheap life should live in a small town. If
they do that, maybe they spend their life in a good situation.
Ans: 18
Ravi and Rupali are asked to write a program to sum the rows of a 2X2 matrices
for n = 0 to 1 sumRow1[n] =
A[n][1] + A[n][2] end
Abhinav wants to find the largest number in a given list of 20 numbers. Which of the
Op 1: Use bubble sort to sort the list in descending order and then print the first number of the
series.
Op 2: Use selection sort to sort the list in descending order and then print the first number of
the series.
Op 3: Implement one iteration of selection sort for descending order and print the first
number
in the series.
Op 4: None of these
Consider an array on which bubble sort is used. To which of the given elements will the bubble
sort compare the element A[x] with, in a single iteration.
a. A[x+1]
b. A[x+2]
C. A[x+2x]
Sharmili wants to make a program to print the sum of all perfect cubes, where the
value of the cubes go from 0 to 100. She writes the following program:
integer i = 0, a // statement 1
integer sum = 0; a = ( i * i * i )
= i + 1 a = ( i * i * i ) //
statement 4
print sum
Does this program have an error? If yes, which one statement will you modify to
Op 1: Statement 1
Op 2: Statement 2
OP 3:statement 3
Op4:statement 4
Op5:no error
Ans: 411
A librarian has to rearrange the library books on a shelf in a proper order at the end of each day.
Which of the following sorting techniques should be the librarian's ideal choice?
Ans: Insertion sort
Each time an object is created using a new() keyword, at least one constructor (it could be the
default constructor) is invoked to assign initial values to the data members of the same class. A
constructor is invoked at the time of object or instance creation.
Vexing meaning
A programmer writes a code snippets in which set of 3 lines occurs 10 times in different
pathway programs what program concepts should be used to shorten code length.
Ans: The programming concept that the programmer should use here is modularity or
looping.
Of all the fitness and wellness activities customary in india, artistic yoga is the new kid in
town. it has successfully earned a pat on the back from whosoever has lent an ear to the
latest advancements. artistic yoga combines the suaveness of yoga and the frenzy of modern
cardio-vascular exercises. the technique involves performance of various aasanas and
pranayams followed by walking on treadmill, stair climbing, cycling and so on. the
activities are performed in a cyclic order and the aasana or pranayam that is done in the
beginning is repeated in the end.
Ans: all the activities formed at the beginning of artistc yoga and also repeated at the end
The unique Iron Age Experimental Centre at Lejre, about 40 km west of Copenhagen,
serves as a museum, a classroom and a place to get away from it all. How did people live
during the Iron Age? How did they support themselves? What did they eat and how did
they cultivate the land? These and a myriad of other questions prodded the pioneers of the
Lejre experiment.
Living in the open and working 10 hours a day, volunteers from all over Scandinavia led by
30 experts, built the first village in the ancient encampment in a matter of months. The
house walls were of clay, the roofs of hay - all based on original designs. Then came the
second stage - getting back to the basics of living. Families were invited to stay in the
'prehistoric village' for a week or two at a time and rough it Iron Age-style.
Initially, this experiment proved none too easy for modern Danes accustomed to central
heating, but it convinced the centre that there was something to the Lejre project. Little by
little, the modern Iron Agers learnt that their huts were, after all, habitable. The problems
were numerous - smoke belching out from the rough-and-ready fireplaces into the rooms
and so on. These problems, however, have led to some discoveries: domed smoke ovens
made of clay, for example, give out more heat and consume less fuel than an open fire, and
when correctly stoked, they are practically smokeless.
By contacting other museums, the Lejre team has been able to reconstruct ancient weaving
looms and pottery kilns. Iron Age dyeing techniques, using local natural vegetation, have
also been revived, as have ancient baking and cooking methods.
A) What is the main purpose of building the Iron Age experimental center?
a) Prehistoric village where people can stay for a week or two to get away from modern
living
b) Replicate the Iron Age to get a better understanding of the time and people of that era
c) To discover the differences between a doomed smoke oven and an open fire to identify
the more efficient of the two
d) Revive activities of ancient women such as weaving, pottery, dyeing, cooking and baking
Solution: Option b
B) What is the meaning of the sentence "Initially, this experiment proved none too easy for
modern Danes accustomed to central heating, but it convinced the centre that there was
something to the Lejre project."?
a) Even though staying in the huts wasn't easy for the modern people, the centre saw merit
in the simple living within huts compared to expensive apartments
b) Staying in the huts was quite easy for the modern people and the centre also saw merit in
the simple living within huts compared to expensive apartments
c) The way of living of the Iron Age proved difficult for the people of the modern age who
are used to living in luxury
d) The way of living of the Iron Age proved very easy for the people of the modern age
since it was hot inside the huts, and they were anyway used to heated rooms
Solution: Option c
Solution: Option d
D) From the passage what can be inferred to be the centre's initial outlook towards the
Lejre project?
b) It eagerly supported it
Solution: Option a
AUTOMATA FIX:
Q) 1
11
111
int print=1,i,j;
for(i=0;i<num;i++)
for(j=0;j<=i;j++);
printf(“%d “,print);
printf(“\n”);
else
return 0;
applied.
return 1;
else
return 0;
float res=1;
if(exponentValue >=0)
res=(float) positiveExponent(baseValue,exponentValue);
}
else
return res;
if (a == 0)
return 0;
else
return 1;
Q) sorting problem
int x=0,y=0;
for(x=0;x<len;x++){
int index_of_min=x;
for(y=x;y<len;y++){
if(arr[index_of_min]>arr[x]){
index_of_min=y;
int temp=arr[x];
arr[x]=arr[index_of_min];
arr[index_of_min]=temp;
int small,pos,i,j,temp;
for(i=0;i<=len-1;i++){
for(j=i;j<len;j++){
temp=0;
if(arr[i]>arr[j]){
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
On Thursday night, a crowd gathered at Union Square in Manhattan for a fond and.
spontaneous memorial to Michael Jackson. A few hundred onlookers formed a circle, leaving
enough space in the middle for the grand standers and the brave to dance like the King of
Pop', or try to Watching this spectacle, you had to wonder: When will this happen again?
When will another pop culture figure mean so much to so many that people are moved to
* Thriller", that spent more than 31 weeks at the top of the Billboard charts. It's one of those
high-water marks that nobody will touch because record stores are vanishing, and along with
them, mega-hit albums are vanishing too. And it's rare for an album to last even three weeks
at the top
When the Beatles were on "The Ed Sullivan Show" in 1964, more than 70 million people
watched it, that is more than one hird of the entire population of the United States, Yes, the
Beatles were that good. But at that time, there were three networks and the radio. No online
messaging apps, video games, movie multiplexes, malls or a dozen other potential drains on
an audience. There weren't a lot of rock bands, either. And now that anyone with a computer
has a miniature studio, and anyone with an internet connection can post a song, there are
sentance mistake
Correct sentence:
1- On Thursday night, a crowd gathered at Union Square in Manhattan for a fond and
spontaneous memorial to Michael Jackson.
2- A few hundred onlookers formed a circle, leaving enough space in the middle for the
grandstanders and the brave to dance like the King of Pop. or try to.
4- Michael Jackson has sold an estimated 100 million copies worldwide of the 1982 album
"Thriller", that spent more than 31 weeks at the top of the Billboard charts. It's one of
those high-water marks that nobody will touch because record stores are vanishing, and
along with them, mega-hit albums are vanishing, too.
5- And it's rare for an album to last even three weeks at the top.
6- When the Beatles were on "The Ed Sullivan Show" in 1964, more than 70 million people
watched it, that is, more than one-third of the entire population of the United States.
What is the function contained within a class is called?
10 7 10 12 14
Ans:13
Lexical meaning
One day raja left home and cycled 5km southwards then turned left and cycled 3km and
again turned left and cycled 2km. How kms to straight to raja home.
Ans: 7.28 km
Ans: krkzo
What is the least no. By which 16800 is divided and is perfect square root
Ans:159
Value of (1/512)^1/9
Ans: ½
If k is integer divided by 2 5 and 13 then what is the nxt integer divided by these 3
K+130 or 260
Computer is written with this code GKQLYPIN the Senate is written in which code?
Ans: WARWXA
The number 456'85 is completely divisible by 3. smallest whole digit number in place of can
be:
Ans: 2
Shobhit bought 300 litres of milk at rs. 19 per litre. He added 200 litres of water to it and
sold 400 litres of this milk at rs. 20 per litre. To the rest, he added 10 litres more water and
then sold it for rs. 15 per litre. If he used mineral water that costs rs.10 per litre, then the
total money earned by shobhit is:
Ans: 1850
Ans: -4.4
X walks 6 km towards east from a point a and from the same point a, y walks 8 km towards
south. How far are the two friends from each other now?
Ans: 10km
Ans: 19
Ans: when a function is called, some value is passed by the calling function, known as the
argument.
Ans: vnqj
Ans: 20
If the square of one number is 25 and LCM and HCF of those two numbers are 5 and 35
respectively, then what is the other number?
Ans: 35
What is the difference between LCM and HCF of 20, 30, 40?
Ans: 110
Correct the sentence incase of any error : She has been lived in Michigan since 2020.
Ans: She has been living in Michigan since she was eight.
3. Base and derived classes are abstractions for each other. 4. Inheritance prevents abstraction
int main() {
integer a=984,b=10;
float c=a/b;
printf(c) ;
Ans: 98.000000
A machine worth 1,80,000 decreases 18% per annum. What is the worth of it after 18 months?
Ans: 134,316
Ans: 6
Nature provides us with much but when we abuse nature we risk disaster write response
explaining how we harm ourselves when we harm environment. Essay
Natural capital is everything nature provides us for free. It is what our economy is built upon. We
add man-made capital in the shape of houses, factories, offices and physical infrastructure, and
human capital with our skills, ideas and science.
Natural capital should, therefore, be at the heart of economics and economic policy – but it isn’t.
As a consequence we abuse nature, drive species to extinction, and destroy ecosystems and
habitats without much thought to the consequences. The damage won’t go away; as we wipe out
perhaps half the species on the planet this century and induce significant climate change, the
economic growth we take for granted will be seriously impaired. Put simply, our disregard for
natural capital is unsustainable – it will not be sustained.
Just as we try to maintain and enhance our own assets – our houses, cars and our knowledge and
skills – so too should the broader economy avoid running down its base of natural capital assets.
Some natural assets will be used up – such as the non-renewables like North Sea oil and gas –
but even here we should be mindful of compensating future generations for what we will not
therefore bequeath to them.
The natural assets that really matter are the renewables – the ones nature keeps on providing us
for free, forever – provided we don’t deplete them beyond the threshold of sustainable
reproduction. We can for example carry on for hundreds of thousands of years harvesting herring
from the North Sea, as long as we do not overfish them. The potential value of all those fish
forever is enormous.
For the economy as a whole, national accounts need to provide for this capital maintenance as a
first call on its revenue. If they did, and if we had a proper balance sheet, then the economic
growth declared would be the sustainable one. It would be lower, too. Put another way, by not
maintaining our assets, we are living beyond our means – let alone also borrowing from the
future to finance the deficit, and making future generations pay for our excessive current
consumption.
A sustainable level of economic growth – driven by all the new technologies that keep coming
along – would be lower, but we would nevertheless be better off in the long run. We would not
then face the consequences of the loss of so much of our natural environment and climate
change.
Unlike the climate change problem, natural capital has a big spatial dimension. Climate change is
all about a small number of gases in the atmosphere and it does not matter where they are
emitted. Natural capital comes at every level, and location matters. It includes the great global
biodiversity hotspots, like the Amazon, and it includes everyone’s backyard and every park and
garden. Everyone can therefore make a difference to natural capital in ways that they cannot to
the climate change problem.
Think of some of the things you could do today. If your front garden is paved and concreted over,
you could break it up and allow wild flowers to flourish, which in turn would help the bees. So
barren is much intensive agricultural land , as it is sprayed with pesticides and herbicides and its
soils supplemented with nitrogen fertilisers, that bees often find cities much better habitats than
the countryside. You could put away the slug pellets and the weed killer.
But the really big gains come from three policy changes, all of which have an impact on the
choices we make. The first is compensation: the idea that if damage is done to our natural
capital, there must be compensating increases elsewhere. The second is pollution taxes, paying
for the damage caused from carbon, pesticides and other emissions. The third is a nature fund,
created from the running down of the non-renewables like North Sea oil and gas.
As Britain faces a population increase of around10 million in the next couple of decades, and as
all the main political parties are committed to building more than 200,000 houses per year, the
HS2 high-speed railway which will initially link London and Birmingham, and more airport
runways, there is little doubt that the natural environment faces challenges matched only by the
devastation caused by the intensification of agriculture encouraged by the Common Agricultural
Policy.
Natural capital is in for a shock, unless compensating improvements are made. These could be
really big – improvements in complete river catchments like the Thames and new marine
protected areas. They can be small and local too; every urban citizen could be guaranteed access
to a green space within 500m of where they live, addressing not only the space children need to
play outdoors, but also the poor air quality that blights our cities. These are parts of the prize of
taking natural capital seriously.
Ans: 5,000 Rs
A number X when divided by 13 leaves remainder 12 what is the remainder when we divided
X^13 by 13?
Ans: 12
An employee has to attain 70% marks during appraisals to get a promotion. He gets 75 marks
and doesn't qualify for a promotion since he falls short of 30 marks in the ratings. What is the
maximum score that an employee can attain in the appraisal ratings?
Ans: 150
This new technology has the potential to provide handsome returns even though it is at a ______
stage in India.
Ans: Nascent
Which data structure may produce an overflow error even though the current number of elements
in it lower than its size
Ans: Queue
Ans: As soon as I turn the ignition key, the engine caught fire.allturn an ignition key
Ans: Circumspect
A function in the base class is redefined in inherited class. Which method describes this
situation?
Overloading
The market was full of people ……….. attractive clothes of different styles.
Ans: wearing
Sort array in c:
if(len%2 == 0)
for(i=0;i<len;i++)
max=arr[i];
location = i;
for(j=i;j<len;j++)
if(max>arr[j])
max=arr[j];
location = j;
temp=arr[i];
arr[i]=arr[location];
arr[location]=temp;
else
for(i=0;i<len;i++)
max=arr[i];
location = i;
for(j=i;j<len;j++)
if(max<arr[j])
max=arr[j];
location = j;
}
temp=arr[i];
arr[i]=arr[location];
arr[location]=temp;
Count digits in c
#include <stdio.h>
int main() {
long long n;
int count = 0;
scanf("%lld", &n);
while (n != 0) {
n /= 10; // n = n/10
++count;
int number[30];
int i, j, a, n;
printf("Enter the value of N\n");
scanf("%d", &n);
}
Binary search in c:
#include <stdio.h>
int main()
scanf("%d", &n);
scanf("%d", &array[c]);
scanf("%d", &search);
first = 0;
last = n - 1;
middle = (first+last)/2;
first = middle + 1;
break;
}
else
last = middle - 1;
return 0;
What does the following function do? Function operation (int a, int b) {
if (a < b)
{return operation (b, a)
}
else {
return a}}
Ans : Returns the max of (a,b)
A programmer is making a database of animals in a zoo and their properties. The possible
animals are dog, lion and zebra. Each one has as attributes isHerbivorous, colour and
isNocturnal. She uses the object oriented programming paradigm for this. How will she
conceptualize the system?
Ans : The system must be designed in the following way - class: Animal; objects: dog, lion and
zebra; data members: is Herbivorous, colour and is Nocturnal.
Choose the correct answer. A pseudo-code which is similar to that of C++ and self-explanatory
An accessible member function or data member for an object are accessed by the statement
objectname.functionname or objectname. data member name respectively. class brush
{ Private: integer size, colorcode
function getdata( ) {–}//Statement 1 public: integer name // Statement 2
function putdata(){…} }
function main { brush b1, b2
print bl.name //Statement 3
b2.getdata() //Statement 4 }
Deleting which line will correct the error in the code?
Ans : Statement 4
A sorting algorithm traverses through a list, comparing adjacent elements and switching them
under certain conditions.What is this sorting algorithm called?
Ans : Quick Sort
A sorting algorithm iteratively traverses through a list to exchange the first element with any
element less than it. It then repeats with a new first element. What is this sorting algorithm
called?
Ans : Selection sort
What will be the output of the following pseudo-code statements:
integer a = 456, b, c, d =10 b = a/d c = a - b print c
Ans : 411
A language has 28 different letters in total. Each word in the language is composed of
maximum 7 letters. You want to create a data-type to store a word of this language.
You decide to store the word as an array of letters. How many bits will you assign to
the data-type to be able to store all kinds of words of the language.
Ans : 35 bits
Which of the following sorting method is stable ?
Ans : Binary Insertion Sort
A programmer writes a program to find an element in the array A[5] with the elements: 8 30 40
45 70. The program is run to find a number “X”, which is found in the first iteration of binary
search. What is the value of “X”?
Ans : 40
A developer writes the program given below to print the sum of the squares of the first five
whole numbers (0 .. 4). Is the program correct? If not, which statement should be modified to
correct the program?
integer i = 0 // Statement 1
integer sum = 0 // Statement 2
while (i<5) // Statement 3
{
sum = i*i // Statement 4
i = i + 1 // Statement 5
}
print sum // Statement 6
Ans : Statement 4
x and y are asked to write a program to sum the rows of a 2x2 matrix stored in an array a.
x writes the code (code a) as follows:
for n = 0 to 1
sum row1[n] = a[n][0] + a[n][1]
end
y writes the code (code b) as follows:
sum row 1[0] = a[0][0] + a[0][1]
sum row 1[1] = a[1][0] + a[1][1]
of the following statements is correct about these codes if no loop unrolling is done by the
compiler?
Ans : Code B would execute faster than Code A.
Essay - global Nuclear power
We are witnessing and harnessing the growth use of nuclear technology for power production
and other applications from both developed and developing countries (IAEA, 2011). Regrettably
according to International Atomic Energy Agency (IAEA), more than 100 member States who
use radioactive materials that can be used to make dirty bombs are characterized by
unsatisfactory control and management system (National Research Council, 2007). It is clear that
global security challenges like illicit cross-border trafficking in arms, illegal immigrants, drugs,
radiological, chemical and biological weapons which are global threats to international peace and
security posed by armed conflict, terrorism, weapons proliferation and transnational organized
crime groups cannot be managed by a single country (United Nations, 2016, IFPA, 2010). This is
why nuclear and other radioactive materials are required by the IAEA for member States to have
a tough alternative protection with effective capabilities to spot and capture their illegal
movement both at borders and within their States (IAEA, 2007). Regardless of these
international requirements, the porous borders and limited security resources has been critical
challenge in developing countries which has left number of nuclear and other radioactive
materials out of regulatory control.
The community engagement in security has been emphasized in fight against local and global
crimes, for instance community has been engaged in fight against extremist groups, to improve
illegal immigration, drug abuse, and other community security challenges.Proper community
engagement in radioactive materials security across the borders and within States with porous
borders and limited security resources can help to improve the response of enforcement agents to
illicit and other cross border crimes.
Which sorts has avg and worst case as O(nlogn)?
Ans : Heap Sort
Pattern
a
ab
abc
#include<stdio.h>
int main()
{
int row,j;
for (row='A'; row<='C'; row++)
{
for (j='A'; j<=row; j++)
{
printf("%c", j);
}
printf("n");
}
return 0;
}
#include <stdio.h>
struct TIME {
int seconds;
int minutes;
int hours;
};
int main() {
struct TIME startTime, stopTime, diff;
In our guest to discover unknown things and to invent new things we have reached a stage where
it is unimaginable and impossible to live without technology. Technology has been gradually
taking over our lives and we are not even aware of the fact that we have become slaves to
technology. We have become too dependent and reliant on technology that if it were to be taken
away from us we would confused and lost.
Technology is helping us in many ways like financial transaction, buying food and stuffs, paying
our bills and booking our flight tickets in the comfort of our home. Similarly we can online
education and degrees, instant medical advice on health issues, watching our favorite movies and
many more. But although technology has been helping us, it has been pulling us away from the
real world.
Human beings are social beings. We love the latest technological gadgets which help people to
connect and communicate with each other. But in the process we have lost authentic
relationships. Technology does not allow us to work as a team of real humans with real
connection.
Psychologically, the silence without real human social life is making us more isolated and lonely.
Depression is increasing but we don't like to blame technology because it has become a way of
life for us.
Technology has stolen our physical well-being. We have less physical activities and many of our
body parts are becoming less inactive and shutting down. New technologies can empower us to
connect with people anywhere in the world. But the harsh reality is that these technologies have
divided us. Within the last decade we have steadily and gradually become slaves to technology,
we have become actors in our own story.
output in c
Ans : 98
Saloni writes the code for a function that takes as input n, an even integer and
function sum( n )
if(n equals 2)
return 2
else
return (n + sum(n-2))
end
She then calls the function by the statement, sum(30). How many times will the function
Question
Ans 16
In the following sorting procedures, which one will be the slowest for any given array? (a)Quick
sort (b)Heap sort (c)Merge Sort (d)Bubble sort
Heap sort
Pankaj and Mythili were both asked to write the code to evaluate the following expression:
a - b+ c/(a-b) + (a-b)^2
The tight curriculum of our education system leaves no room for imagination and
creativity.Essay
I whole heartedly agree that the tight curriculum of our current education system leaves no room
for imagination and creativity. The academic pressure is so much on them, they have forgotten
their innate creativity and imagination. They are always under the pressure of studies. This
pressure is put on them from the beginning of the session. Formative assessment activities of all
the subjects, studies and their assignments of all the subjects, unit tests, co-curricular activities,
homework, classwork, projects, practical exams, summative examination, date sheet, result,
again the new term, etc. So much of pressure on the young growing children! Are we educating
them or training them the art of being stressful throughout their childhood?
Even while studying inside class, they feel so burdened; they have come to dislike education. as
a result there is hardly any creativity left in our country. Every year all the illustrious prizes for
creativity are won by non-Indians or Indians living in advanced countries. Our educationists
must rethink and revise the curriculum to encourage creativity and imagination in children --- not
rot learning.
Ans : 31
Waxing means
the process of removing unwanted hair from a part of the body by applying wax and peeling off
the wax and hairs together.
#include <bits/stdc++.h>
// given coordinates
and (A == (B + C) or B == (A + C)
or C == (A + B)))
else
// Driver Code
int main()
int X1 = 0, Y1 = 2;
int X2 = 0, Y2 = 14;
int X3 = 9, Y3 = 2;
return 0;
Fibonacci series in c:
include<stdio.h>
int main()
int n1=0,n2=1,n3,i,number;
printf("Enter the number of elements:");
scanf("%d",&number);
n3=n1+n2;
printf(" %d",n3);
n1=n2;
n2=n3;
return 0;
A binary tree with the property that the values at each node is at least as large as the values at its
children in known as
AVL tree
C
Completely balanced tree
Heap
answer:Heap
Sort array in c:
1. #include <stdio.h>
2. void main()
3. {
4.
5. int i, j, a, n, number[30];
6. printf("Enter the value of N \n");
7. scanf("%d", &n);
8.
9. printf("Enter the numbers \n");
10. for (i = 0; i < n; ++i)
11. scanf("%d", &number[i]);
12.
13. for (i = 0; i < n; ++i)
14. {
15.
16. for (j = i + 1; j < n; ++j)
17. {
18.
19. if (number[i] > number[j])
20. {
21.
22. a = number[i];
23. number[i] = number[j];
24. number[j] = a;
25.
26. }
27.
28. }
29.
30. }
31.
32. printf("The numbers arranged in ascending order are given below \n");
33. for (i = 0; i < n; ++i)
34. printf("%d\n", number[i]);
35.
36. }
Count digits in c:
#include <stdio.h>
int main() {
long long n;
int count = 0;
scanf("%lld", &n);
while (n != 0) {
n /= 10; // n = n/10
++count;
#include <stdio.h>
void main()
int arr1[100];
printf("--------------------------------------------------\n");
printf("Input the number of elements to be stored in the array :");
scanf("%d",&n);
for(i=0;i<n;i++)
printf("element - %d : ",i);
scanf("%d",&arr1[i]);
mx = arr1[0];
mn = arr1[0];
if(arr1[i]>mx)
mx = arr1[i];
}
if(arr1[i]<mn)
mn = arr1[i];
Median program in c:
#include <stdio.h>
int t;
t=*p;
*p=*q;
*q=t;
}
void sort(int a[],int n) {
int i,j,temp;
swap(&a[j],&a[j+1]);
int main() {
int n = 5;
int sum,i;
sort(a,n);
When a function in the base class is redefined in the inherited class is called?
Overriding is the word when a function belonging to the base class is redefined in the
inherited class which is part of Java language. It is a language feature that allows a
subclass or child class to provide a specific implementation of a method that is already
provided by one of its super classes or parent classes.
Selection sort:
#include <stdio.h>
int main() {
int arr[10]={6,12,0,18,11,99,55,45,34,2};
int n=10;
position = i;
position = j;
if (position != i) {
swap = arr[i];
arr[i] = arr[position];
arr[position] = swap;
printf("%d\t", arr[i]);
return 0;
}
Question 1
The function/method patternPrint accepts an argument num, an integer.
The function/method patternPrint prints num lines in the following
pattern.
For example, num=4 the pattern should be
1
11
111
1111
The function/method patternPrint compiles successfully but fails to print
the desired result for some test cases due to incorrect implementation of
the function/method.Your task is to fix the code so that it passes all the
test cases.
void patternPrint(int num)
{
int print=1,i,j;
for(i=0;i<num;i++)
{
for(j=0;j<=i;j++);
{
printf(“%d ”,print);
}
printf(“\n”);
}
}
Solution:
void patternPrint(int num)
{
int print=1,i,j;
for(i=0;i<num;i++)
{
for(j=0;j<=i;j++)
{
printf(“%d”,print);
}
printf(“\n”);
}
}
Question 2
Lisa always forgets her birthday which is on the 5th of July.So, develop
a function/method which will be helpful to remember her birthday.
The function/method checkBirthDay returns an integer '1' if it is her
birthday else returns 0.The function/method checkBirthDay accepts two
arguments - month, a string representing the month of her birthday and
day an integer representing the date of her birthday.
The function/method checkBirthDay compiles successfully but fails to
print the desired result for some test cases due to incorrect implementation
of the function/method.Your task is to fix the code so that it passes all the
test cases.
int checkBirthDay(char* month,int day)
{
if((strcmp(month,”July”))|| (day==5))
return 1;
else
return 0;
}
Solution:
int checkBirthDay(char* month, int day)
{
if((strcmp(month,”July”)==0) && (day==5))
return 1;
else
return 0;
}
Question: 3
Solution:
Testcase 1:
Input: 5, 2
Expected Return Value: 25.00000
Testcase 2:
Input: 5, -2
Expected Return Value: 0.04000
Question: 4
You are given a predefined structure Point and also a collection of related
functions/methods that can be used to perform some basic operations on
the structure.
You must implement the function/method isTriangle which accepts three
points P1, P2, P3 as inputs and checks whether the given three points form
a triangle.
If they form a triangle. the function/method returns an integer 1.
Otherwise, it returns an integer 0. Helper Description
The following structure is used to represent point and is already
implemented in the default code (Do not write these definitions again in
your code):
Code:
struct point;
typedef struct point{
int X;
int Y;
}Point;
double Point calculateDistance(Point *point1, Point *point2)
int isTriangle(Point *p1, Point *p2, Point *p3)
{
//write your code here
}
Solution:
Testcase 1:
Input:
(3,4),
(2,1),
(1, 5)
Expected Return Value: 1
Testcase 2:
Input:
(1,-1),
(0,-1),
(- 1, - 1)
Expected Return Value: 0
Question 5
Solution:
int matrixSum(int rows, int columns, int **matrix)
{
int i, j,sum=0;
for(i=0; i<rows; i++)
{
for(j=0; j<columns; j++)
sum += matrix[i][j];
}
return sum;
}
Question 6
Solution:
Given function:-
int small,pos,i,j,temp;
for(i=0;i<=len-1;i++)
for(j=i;j<len;j++)
temp=0;
if(arr[i]>arr[j])
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
Solution:-
Int i,j,temp;
for(i=0;i<=len-1;i++)
for(j=i;j<len;j++)
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
Question 8
Note:
for(i=0;i<=size-1;i++)
if((inputList[i]%2==0)&&(inputList[i]==inputList[i+1]))
count++;
return count;
Input:-
11,
[1,5,5,2,2,7,8,6,6,9,10]
2
Test case:-2
Input:
5,
[13,12,12,13,14]
Question 9
Solution:
int countOccurence(int len, int value,int *arr)
{
int i=0,count=0;
while(i<len)
{
if(arr[i]==value)
{
count+=1;
}
i++;
}
return count;
}
Question 10
Solution
float median(int size,int *inputList)
{
int start_index=0;
int end_index=size-1;
float res=-1;
if(size%2!=0)
{
int med_1=size/2;
int med_2=(size/2)+1;
res=((float)quick_select(inputList,start_index,end_index,med_1));
}
else
{
//enter your code here
res=((float)quick_select(inputList,start_index,end_index,med_1)+(float)
quick_select(inputList,st
art_index,end_index,med_2))/2;
}
return res;
}
Question 11
Solution:
void manchester(int len,int *arr)
{
int* res=(int)malloc(sizeof(int)*len);
res[0]=arr[0];
for(int i=1;i<len;i++)
{
res[i]=!(arr[i]==arr[i-1]);
}
for(int i=0;i<len;i++)
printf(“%d ”,res[i]);
}
Question 12
Solution:
int isRightTriangle(Point *P1,Point *P2,Point *P3)
{
double d1,d2,d3;
d1=Point_calculateDistance(P1,P2);
d2=Point_calculateDistance(P2,P3);
d3=Point_calculateDistance(P3,P1);
if(pow(d1,2)+pow(d2,2)==pow(d3,2)||pow(d2,2)+pow(d3,2)==pow(d1,2)||pow((d3,2)+pow(d1,2)==pow(d2,2) )
{
return 1;
}
else
return 0;
}
Question 13
You are required to fix all syntactical errors in the given code. You
can click on Compile & Run anytime to check the
compilation/execution status of the program. You can use printf()
to debug your code. The submitted code should be
logically/syntactically correct and pass all testcases. Do not write
the main function as it is not required.
Code Approach: For this question, you will need to correct the
given implementation. We do not expect you to modify the
approach or incorporate any additional library methods.
Solution:
void drawPrintPattern(int num)
{
int i,j,print=1;
for (i=1;i<=num;i++)
{
for (j=1;j<=2*i;j++)
{
printf("%d ",print);
}
printf ("\n");
}
}
Testcase 1:
Input: 5, 7, 4
Expected Return Value:
35
Testcase 2:
Input: 11, 12, 13
Expected Return Value:
156
Question 14
You are required to fix all logical errors in the given code. You can click
on Compile & Run anytime to check the
compilation/execution status of the program. You can use printf() to
debug your code. The submitted code should be
logically/syntactically correct and pass all testcases. Do not write the
main() function as it is not required.
Code Approach: For this question, you will need to correct the given
implementation.
11
1111
111111
The function/method drawPrintPattern compiles successfully but fails to
get the desired result for some test cases due to
incorrect implementation of the function/method. Your task is to fix the
code so that it passes all the test cases.
Solution:
int multiplyNumber(int numA,int numB,int numC)
{
int result,min,max,mid;
max=(numA>numB)?((numA>numC)?numA:numC):((numB>numC)?numB:numC);
min=(numA<numB)?((numA<numC)?numA:numC):((numB<numC)?numB:numC);
mid=(numA+numB+numC)-(min+max);
result=(max*mid);
return result;
}
Testcase 1:
Input: 4
Expected Return Value:
11
1111
111111
11111111
Testcase 2:
Input: 1
Expected Return Value:
11
Question 15
Solution:
int difference_in_Dates(Date *Date1, Date *Date2)
Return *Date2-*Date1;
Question 16
Solution:
int i;
if(size>0)
for(i=0; i<size;i++)
{
if(max<arr[i])
{
max = arr[i];
else
if(min>arr[i])
{
min= arr[i]
for(i=0;i<size;i++)
if(arr[i] %2 ==0)
arr[i]=max;
else
arr[i] = min;
}
}
Question 17
Solution:
#include <stdio.h>
void printPattern(int num)
{
int i,j;
for(i=1;i<=num;i++)
{
for(j=1;j<=2*i;j++)
{
printf("%d ",i);
}
printf("\n");
}
}
Question 18
Solution:
#include <stdio.h>
void printFibonacci (int num)
{
int i;
long sum = 0;
long num1 = 0;
long num2= 1;
for (i = 1; i <= num; ++i)
{
printf("%ld ", num1);
sum = num1 + num2;
num1 = num2;
num2=sum;
}
}
Question 19
The function/method manchester print space seperated integers with the
following property.
For each element in the input arr,a counter is incremented if the bit arr[i]
is sasme as arr[i-1]. Then the increment counter
value is added to the output array to store the result.
If the bit arr[i] and arr[i-1] are not same then the output is added with 0.
For the first bit in the arr, assume its previous bit to be 0.
For example, id arr is {0,1,0,0,1,1,1,0} then the output would be 1 0 0 2 0
3 4 0.
Solution:
#include<stdbool.h>
void manchester(int size, int* arr){
bool result;
int* res=(int*)malloc(sizeof(int)*size);
int count=0;
for(int i=0;i<size;i++)
{
if(i==0)
result= (arr[i]==0);
else
result= (arr[i]==arr[i-1]);
res[i]=(result)?(++count):0;
}
for(int i=0;i<size;i++)
{
printf("%d ",res[i]);
}
}
Test Case 1:
Input:
6
[1,1,0,0,1,0]
Output:
010200
Test Case 2:
Input:
8
[0,0,0,1,0,1,1,1]
Output:
12300045
Question 20
The function/method reverseHalfArray modify the inputList by reversing
the input list from the second half. The function takes size and array as
arguments.
Solution:
void reverseHalfArray(int size, int* inputList){
int i,temp;
for(i=(size/2);i<size;i++)
{
temp=inputList[size-1];
inputList[size-1]=inputList[i];
inputList[i]=temp;
size-=1;
}
}
Test Case 1:
Input:
7
[1,2,3,4,5,6,7]
Output:
1237654
Test Case2:
Input:
4
[2,8,4,6]
Output:
2864
Question 21
Solution:
int isRightTriangle(Point *P1,Point *P2,Point *P3)
{
double d1,d2,d3;
d1=Point_calculateDistance(P1,P2);
d2=Point_calculateDistance(P2,P3);
d3=Point_calculateDistance(P3,P1);
if(pow(d1,2)+pow(d2,2)==pow(d3,2)|| pow(d2,2)+pow(d3,2)==pow(d1,2)|| pow(d3,2)+pow(d1,2)==pow(d2,2))
{
return 1;
}
else return 0;
}
Question 22
Solution:
void printCharacterPattern(int num)
{
int i,j;
char ch='a';
char print;
for(i=0;i<=i;j++)
{
printf("%c",print++);
}
printf("\n");
}
}
Question 23
You are required to fix all logical errors in the given code. You can click
on Compile & Run anytime to check the compilation/execution status of
the program. You can use printf() to debug your code. The submitted code
should be logically/syntactically correct and pass all testcases
Code Approach: For this question, you will need to correct the given
implementation. We do not expect you to modify the approach.or
incorporate any additional library methods.
int count=0;
int k=num;
while(num!=0)
{
num=num/10;
++count;
}
return (k%count);
}
Testcase 1:
Input:
782
Testcase 2:
Input:
21340
Question 24
You are required to complete the given code. You can click on Compile &
Run anytime to check the compilation/execution status of the program.
You can use printf() to debug your code. The submitted code should be
logically/syntactically correct and pass all testcases. Do not write the main
function as it is not required.
Code Approach: For this question, you will need to complete the code as
in given implementation. We do not expect you to modify the approach.
Input:
31
Testcase 2:
Input:
[day:01, month:06, year: 2011), (day:01, month:06, year:2012)
366
Question 25
Solution:
void arrayReverse(int len,int *arr)
{
int i,temp,originalLen=len;
for(i=0;i<=originalLen/2;i++)
{
temp=arr[len-1];
arr[len-1]=arr[i];
arr[i]=temp;
len-=1;
}
}
Question 26
Solution:
Question 27
Solution:
void removeElement(int size, int indexValue, int *inputList)
{
int i,j;
if(indexValue<size)
{
for(i=indexValue;i<=size-1;i++)
{
inputList[i]=inputList[i+1];
}
for(i=0;i<size-1;i++)
printf(“%d “,inputList[i]);
}
else
{
for(i=0;i<size;i++)
printf(“%d “,inputList[i]);
}
}
Question 28
Solution
int* sortArray(int len,int* arr)
{
int i=0,j=0,temp=0;
for(i=0;i<len;i++)
{
for(j=i+1;j<len;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
return arr;
}
Int findMaxElement(int len1, int* arr1, int len2, int* arr2)
{
sortArray(len1,arr1);
sortArray(len2,arr2);
if(arr1[len1-1]>=arr2[len2-1])
return arr1[len1-1];
else
return arr2[len2-1];
}
Question 29
Solution: -
void manchester(int len, int* arr)
{
int* res = (int*)malloc(sizeof(int)*len);
res[0] = arr[0];
for(int i = 1; i < len; i++)
{
res[i] = (arr[i]!=arr[i-1]);
}
for(int i=0; i<len; i++)
printf(“%d “,res[i]);
}
Question 30
Solution: -
int multiplyNumber(int numA, int numB, int numC)
{
int result,min,max,mid;
max=(numA>numB)?((numA>numC)?numA:numC):((numB>numC)?numB:numC);
min=(numA<numB)?((numA<numC)?numA:numC):((numB<numC)?numB:numC);
mid=(numA+numB+numC)-(min+max);
result=(max*mid);
return result;
}
Question 31
Question 32
Question 33
Solution :
int countOccurrence(int len,int value,int *arr)
{
int i=0,count=0;
while(i<len)
{
if(arr[i]==value)
count+=1;
return value;
}
}
Question 34
Solution:
void drawPrintPattern(int num)
{
for(i=1;i<=num;i++)
{
for(j=1;j<=2*i;j++)
{
printf(“%d “,print);
}
printf(“\n”);
}
Question 35
You are required to fix all the logical error in the given code. You can click
on Compile & Run anytime to check the compilation/execution status of
the program. You can use printf() to debug your code. The submitted code
should be logically/syntactically correct and pass all testcases. Do not
write the main() function as it is not required.
Code Approach: For this question, you will need to complete the code as
in given implementation. We do not expect you
to modify the approach.
Note:
Question 36
You are required to complete the given code. You can click on Compile
& Run anytime to check the compilation/execution \
status of the program. You can use printf() to debug your code. The
submitted code should be logically/syntactically
correct and pass all testcases. Do not write the main() function as it is not
required.
Code Approach: For this question, you will need to complete the code as
in given
Problem:
float median(int size,int *inputList)
{
int start_index=0;
int end_index=size-1;
float res=-1;
if(size%2!=0)
{
int median_order=((size+1)/2);
res=(float)quick_select(inputList,start_index,end_index,median-
order);
}
else
{
//enter your code
}
return res;
}
Solution:
float median(int size,int *inputList)
{
int start_index=0;
int end_index=size-1;
float res=-1;
if(size%2!=0)
{
int median_order=((size+1)/2);
res=(float)quick_select(inputList,start_index,end_index,median-
order);
}
else
{
int median_order=((size+1)/2);
res=((float)(quick_select(inputList,start_index,end_index,median-
order)+
quick_select(inputList,start_index,end_index,median-
order)))/2;
}
return res;
}
Testcase 1:
Input: 5,
[2, 40, 23, 52, 37]
Testcase 2:
Input: 6,
[-24, -16, -8, -4, -54, -1]
Expected Return Value:
-12.00
Question 37
given three point find whether they forms a right angled triangle
or not.
int isRightTriangle(Point *p1,Point *p2,Point *p3)
{
}
find the distance between three points. let them be a,b,c.
if a2+b2=c2
then it will be right triangle
Solution:
Question 38
given three point find whether they forms a right angled triangle
or not.
int isRightTriangle(Point *p1,Point *p2,Point *p3)
{
}
find the distance between three points. let them be a,b,c.
if a2+b2=c2
then it will be right triangle
Solution:
Code
void drawPrintPattern(int num)
{
int i,j,print=1;
for(i=1;i<=num;i++)
{
for(j=1;j<=2*i;j++)
{
printf("%d ",print);
}
printf("\n");
}
}
Question 40
Code
int sameElementCount(int size,int *inputList)
{
int i,count=0;
for(i=0;i<size-1;i++)
{
if((inputList[i]%2==0)&&(inputList[i]==inputList[i+1]))
count++;
}
return count;
}
Question 41
Solution
int sameElementCount(int size, int *inputList)
{
int i,count=0;
for(i=0;i<size-1;i++)
{
if((inputList[i]%2==0)&&(inputList[i]==inputList[i+1]))
count++;
}
return count;
}
Question 42
Solution
void manchester(int len, int *arr)
{
int *res= (int*)malloc(sizeof(int)*len);
res[0]=arr[0];
for(int i=1;i<len;i++)
{
res[i]=!(arr[i]==arr[i-1]);
}
for(int i=0;i<len;i++)
{
printf("%d ",res[i]);
}
}
Question 43
Solution:
int multiplyNumber(int numA, int numB, int numC)
{
int result,min,max,mid;
max=(numA>numB)?((numA>numC)?numA:numC):((numB>numC)?numB:numC);
min=(numA<numB)?((numA<numC)?numA:numC):((numB<numC)?numB:numC);
mid=(numA+numB+numC)-(min+max);
result=(max*mid);
return result;
}