The program must accept the diameter of
the circle as a command line argument and print the area of the circle rounding
it up to 2 decimal places.
Example
Input/Output 1:
Input:
14
Output:
154.00
Example
Input/Output 2:
Input:
14.42
Output:
163.38
Solution:
#include <stdio.h>
#include <stdlib.h>
void main(int c,char *b[])
{
float a =...
Saturday, September 30, 2017
Friday, September 29, 2017
Perfect Squares - Till N
Written by Anitha Sri
on September 29, 2017
Given a positive integer N as the input,
print all the perfect squares till N (inclusive of N).
Input
Format:
The first line contains N.
Output
Format:
The first line contains the perfect
squares till N separated by a space.
Boundary
Conditions:
1 <= N <= 9999999
Example
Input/Output:
Input:
20
Output:
1 4 9 16
Solution:
#include <stdio.h>
void printSquare(int...
Thursday, September 28, 2017
Pattern Printing - Start Number
Written by Sammy221
on September 28, 2017
Given an integer N as the input and a
start integer S, print the pattern as given in the Example Input/Output
section.
Input
Format:
The first line contains S and N, each
separated by a space.
Output
Format:
2N lines containing the desired pattern.
Boundary
Conditions:
2 <= N <= 50 1 <= S <= 20
Example
Input/Output:
Input:
3 4
Output:
3
4 4
5 5 5
6 6 6...
Wednesday, September 27, 2017
String - Repeating Alphabets
Written by Anitha Sri
on September 27, 2017
Given a string S as the input, print the
distinct alphabets in S that occur more than once. The alphabets must be
printed based on the order of their occurrence in S.
Input
Format:
The first line contains S.
Output
Format:
The first line contains the distinct
alphabets in S that occur more than once.
Boundary
Conditions:
2 <= LENGTH of S <= 200
Example
Input/Output 1:
Input:...
Tuesday, September 26, 2017
Pattern Printing - Diamond Numbers
Written by Sammy221
on September 26, 2017
Given an integer N as the input, print the
pattern as given in the Example Input/Output section.
Input
Format:
The first line contains N.
Output
Format:
2N-1 lines containing the desired pattern.
Boundary
Conditions:
2 <= N <= 50
Example
Input/Output:
Input:
3
Output:
0 0 1 0 0
0 2 0 8 0
3 0 0 0 7
0 4 0 6 0
0 0 5 0 0
Solution:
n = int(input())
for i...
Monday, September 25, 2017
Pattern - ZigZag Number Square
Written by Sammy221
on September 25, 2017
Given an integer N as the input, print the
pattern as given in the Example Input/Output section.
Input
Format:
The first line contains N.
Output
Format:
N lines containing the desired pattern.
Boundary
Conditions:
2 <= N <= 50
Example
Input/Output:
Input:
5
Output:
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
Solution:
#include<stdio.h>
void...
Saturday, September 23, 2017
Second Largest Value among N integers
Written by Anitha Sri
on September 23, 2017
The program must accept N integers and
print the second largest value among the N integers.
Input
Format:
The first line denotes the value of N.
Next N lines will contain the N integer values.
Output
Format:
The first line contains the second largest
integer.
Boundary
Conditions:
2 <= N <= 100 The value of the integers will be from -999999 to 999999.
Example
Input/Output:...
Thursday, September 21, 2017
First Repeating Character From Last
Written by Sammy221
on September 21, 2017
A string S is passed as the input. S has
at least one repeating character. The program must print the first repeating
character C from the last.
Input Format:
The first line contains S.
Output Format:
The first line contains C.
Boundary Conditions: Length of S
will be from 3 to 100.
Example Input/Output 1:
Input:
abcdexyzbwqpooplj
Output:
p
Solution:
#include <bits/stdc++.h>
using...
Wednesday, September 20, 2017
Prime's Sum
Written by Sammy221
on September 20, 2017
Given a
number N. Find if it can be expressed as
sum of two prime numbers.
Input:
The first line of input contains an integer T denoting the number of test
cases. Then T test cases follow. Each test case contains an integer N as
input.
Output:
For each test case, In new line print "Yes" if it can be expressed,
Otherwise print "No".
Constraints:
1<=T<=2000
1<=N<=106
Example:
Input:
2
34
23
Output:
Yes
No
Solution:
#include
<iostream>
using
namespace...
Matrix Row Sum
Written by Sammy221
on September 20, 2017
Given a R*C matrix (R - rows and C-
Columns), print the sum of the values in each row as the output.
Input
Format:
First line will contain R and C
separated by a space. Next R lines will contain C values, each separated by a
space.
Output
Format:
R lines representing the sum of elements
of rows 1 to R.
Boundary
Conditions: 2
<= R, C <= 50
Example
Input/Output 1:
Input:...
Monday, September 18, 2017
Three Strings
Written by Sammy221
on September 18, 2017
Given
N string values, the program must print 3 string values as the output as
described in the Example Input/Output section.
Input format:
The
first line will contain N denoting the number of string values. Next N lines
will contain the N string values.
Output format:
Three
lines containing string values as described in the Example Input/Output
section.
...
Sunday, September 17, 2017
Head Count - Birds and Animals
Written by Anitha Sri
on September 17, 2017
In a zoo there are some birds and
animals. All birds have two legs and all animals have four legs. Given the head
count and leg count of both birds and animals taken together, the program must
print the head count of birds and animals separated by a space as output.
Input
Format:
First line will contain the integer
value H representing the head count of both birds and animals taken together.
Second...
Saturday, September 16, 2017
Average Speed
Written by Anitha Sri
on September 16, 2017
A single line L with a set of space
separated values indicating distance travelled and time taken is passed as the
input. The program must calculate the average speed S (with precision up to 2
decimal places) and print S as the output.
Note:
The distance and time taken will follow
the format DISTANCE@TIMETAKEN. DISTANCE will be in kilometers and TIMETAKEN
will be in hours.
Input
Format:...
Friday, September 15, 2017
Morning Walk Distance
Written by Sammy221
on September 15, 2017
A man in order to reduce his weight
walks along the boundary of a rectangular plot every morning. Depending on his
energy level he walks for N rounds on a given day. Given the length L and
breadth B of the rectangular plot along with the number of rounds N, the
program must print the total distance D covered in the morning walk.
Note: Do not worry about the units like
meters or kilometers.
Input
Format:...
Thursday, September 14, 2017
Matrix Pattern Printing - First/Last Higher
Written by Sammy221
on September 14, 2017
Given an integer N as the input, print
the pattern as given in the Example Input/Output section.
Input
Format:
The first line contains N.
Output
Format:
N lines containing the desired pattern.
Boundary
Conditions:
2 <= N <= 100
Example
Input/Output 1:
Input:
3
Output:
1 1 1 2
3 2 2 2
3 3 3 4
Solution:
#include <stdio.h>
void printPattern(int n) {...
Wednesday, September 13, 2017
String Letters Frequency
Written by Sammy221
on September 13, 2017
A string value S containing N unique
letters is passed as the input. The program must print the letters in the
string based on the count of their occurrence. The letters of higher frequency
of occurrence must appear first. If two letters have same frequency of
occurrence then they are arranged as per alphabetical order.
Input
Format:
The first line contains S.
Output
Format:
N lines containing...
Monday, September 11, 2017
GCD of N Integers
Written by Sammy221
on September 11, 2017
N integers are passed as input to the
program. The program must print the GCD (HCF) of these N integers.
Input
Format:
The first line contains N. The second line
contains N integers each separated by a space.
Output
Format:
The first line contains the HCF of these N
numbers.
Boundary
Conditions:
2 <= N <= 100
Example
Input/Output 1:
Input:
4
15 20 30 50
Output:...