Srikanth External Lab Answers
Srikanth External Lab Answers
Task Description:
A and B are two friends fond of playing mathematical games. One day they both decided to
play a game. A has to calculate the minimum number of notes required to form the given
amount using the denomination(500,100,50,20,10,5,2,1).
Sample Input:
575
Sample Output:
2. Task Description:
Sample Input:
Sample Output:
Yes
3. Task Description:
Given an Integer X.Find the sin and cosine value of x using Series Expansion.
Sample Input:
78
Sample Output:
0.978141 0.207745
4. Problem Description:
Count the No of primes between two given Integers.
Sample Input:
1 10
Sample Output:
5. Task Description:
Niharika is a scientist and she has designed a robo. The function of Robo is just to walk
forward and backward continuously. One day Niharika went out of the lab and one of the kids
has taken the robo and started observing how it is walking. But there is a ditch on the
forward end and backward which was not observed by the kid. So now we have to check
whether the robo falls in a ditch or not. If it falls, whether it is the forward ditch or backward
ditch and time to fall in a ditch
Input Format:
5 integers denoting no.of forward steps, no.of backward steps, forward ditch position,
backward ditch position, and time taken for single step
Output Format:
F integer. F denotes forward ditch and integer is the time taken by robo to fall in a ditch
B integer. B denotes backward ditch and integer is the time taken by robo to fall in a ditch
Sample Input:
13315
Sample Output:
B 15
6. Task Description:
Input Format:
First line l contains a,b and c, separated by space, where a is the coefficient of x^2 term, b is
the coefficient of x and c is constant .
Output Format:
Print the nature of the roots and roots of the quadratic equation.
Sample Input:
140
Sample Output:
#include<stdio.h>
#include<stdlib.h>
int main()
int i,j,k,l,n;
int **a,**b,**c;
scanf("%d",&n);
a=(int**)malloc(sizeof(int*)*n);
b=(int**)malloc(sizeof(int*)*n);
c=(int**)malloc(sizeof(int*)*n);
for(i=0;i<n;i++)
a[i]=(int*)malloc(sizeof(int)*n);
b[i]=(int*)malloc(sizeof(int)*n);
c[i]=(int*)malloc(sizeof(int)*n);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
k=0;
for(l=0;l<n;l++)
k=k+(a[i][l]*b[l][j]);
c[i][j]=k;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf(" %d",c[i][j]);
printf("\n");
8. Task Description:
Given an integer N representing a number in decimal format. There are two types of queries:
Input Format:
Single Integer N denoting the number in Decimal format and a value X representing type of
query(0 or 1).
Output Format:
Single line containing the number in required format. Print 8 bit binary number .
Sample Input:
00
Sample Output:
0000
9. Task Description:
Sample Input
8
13379246
Sample Output:
#include<stdio.h>
int main()
int n;
scanf("%d",&n);
int arr[n];
int i,j,count=0;
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
int max=0;
int maxpos;
for(i=0;i<n;i++)
count=0;
for(j=0;j<n;j++)
if(arr[i]==arr[j])
count++;
}
if(count>max)
max=count;
maxpos=i;
printf("%d",arr[maxpos]);
Sample Input:
1 -1 2 3
Sample Output:
23
sum=5
program:
#include<stdio.h>
int main()
int n;
scanf("%d",&n);
int arr[n];
int i,j,sum=0;
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
int max=0;
int in1,in2;
for(i=0;i<n;i++)
sum=0;
for(j=0;j<n;j++)
if(i!=j)
sum=arr[i]+arr[j];
if(sum>max)
max=sum;
in1=i;
in2=j;
}
}
printf("%d %d",arr[in1],arr[in2]);
You will be given a string and you need to say how strong it is as a password. conditions are
as follows
1. Strong, when there is at least one numeric, at least one in upper and one in lower
case letter, and a special character.
Input Format:
password
Output Format:
Sample Input:
aK1@m
Sample Output:
Strong
12123
Sample Output:
3
#include<stdio.h>
int main()
int n;
scanf("%d",&n);
int arr[n];
int i,j,odd;
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
odd=arr[0];
for(i=1;i<n;i++)
odd=(odd^arr[i]);
printf("%d",odd);
Sample Input:
35784
Sample Output:
85734
#include<stdio.h>
int main()
int n;
int i,j;
int maxpos,minpos;
scanf("%d",&n);
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
int max=0;
int min=1000000;
for(i=0;i<n;i++)
if(arr[i]>max)
max=arr[i];
maxpos=i;
if(arr[i]<min)
{
min=arr[i];
minpos=i;
arr[minpos]=max;
arr[maxpos]=min;
for(i=0;i<n;i++)
printf("%d ",arr[i]);
Sample Input:
avi
kavi
Ravi
Sample Output:
ravi 1
avi 2
Kavi 3
15. Task Description:
First line contains N, denoting string size. Next line contains a string S. Next line contains
integer variable P, from where n characters starting from that position are to be deleted. Next
line contains a integer variable n, denoting number of characters that are to be delated(i.e,
length of sub string).
Output Format:
Sample Input:
10
HelloWorld
Sample Output:
Hello
Sample Input :
Sample Output :
##
###
Sample Input:
36
Sample Output:
14930352
You will be given no.of students and number of teachers count of all the schools in the city.
You have to sort (Ascending Order) the list based on the number of students. If a tie occurs
then you have to check for the number of teachers
Input Format:
First line contains "n" value. followed by no.of students and number of teachers separated by
a space. Each school data will be present in the new line.
Output Format:
Sample Input:
10 2
98
10 4
12 1
67
Sample Output:
67
98
10 2
10 4
12 1
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
printf(" %d",b[i][j]);
}
printf("\n");
}}
20. Task description
Calculate the frequency of a word in a given paragraph/string.(hint : Use string.h
functions)
if((para[i]>=32&¶[i]<=47)||(para[i]>=58&¶[i]<=64))
{
c++;
}
while((para[i]>=32&¶[i]<=47)||(para[i]>=58&¶[i]<=64))
{
i++;
}
}
printf("%d",c);
}
#include<stdio.h>
#include<string.h>
typedef struct student
{
char name[100];
int roll;
int marks;
}st;
int main()
{
int n,i,j;
printf("enter number of students\n");
scanf("%d",&n);
st s[n],temp;
printf("enter student details\n");
for(i=0;i<n;i++)
{
scanf("%s%d%d",s[i].name,&s[i].roll,&s[i].marks);
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1;j++)
{
if(s[j+1].marks<s[j].marks)
{
temp=s[j+1];
s[j+1]=s[j];
s[j]=temp;
}
}
}
for(i=0;i<n;i++)
{
printf("%s %d %d",s[i].name,s[i].roll,s[i].marks);
printf("\n");
}
}
#include<stdio.h>
#include<string.h>
char name[100];
int roll;
int marks;
}st;
int main()
int n,i,j;
scanf("%d",&n);
st s[n],temp;
for(i=0;i<n;i++)
scanf("%s%d%d",s[i].name,&s[i].roll,&s[i].marks);
}
for(i=0;i<n-1;i++)
for(j=0;j<n-1;j++)
if(strcmp(s[j+1].name,s[j].name)<0)
temp=s[j+1];
s[j+1]=s[j];
s[j]=temp;
for(i=0;i<n;i++)
printf("%s %d %d",s[i].name,s[i].roll,s[i].marks);
printf("\n");