0% found this document useful (0 votes)
14 views21 pages

C Program With Test Cases

This document outlines 7 problems related to prime numbers, composite numbers, and number conversions in C. It provides sample test cases and expected outputs for each problem. The problems include: 1) Displaying prime numbers between two inputs. 2) Checking if a number can be expressed as the sum of two primes. 3) Checking if a number is prime, Armstrong, or neither. 4) Displaying prime numbers between two inputs and their sum. 5) Checking if two numbers are twin primes. 6) Converting an octal number to decimal. 7) Converting a decimal number to octal.

Uploaded by

bhslegion1498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views21 pages

C Program With Test Cases

This document outlines 7 problems related to prime numbers, composite numbers, and number conversions in C. It provides sample test cases and expected outputs for each problem. The problems include: 1) Displaying prime numbers between two inputs. 2) Checking if a number can be expressed as the sum of two primes. 3) Checking if a number is prime, Armstrong, or neither. 4) Displaying prime numbers between two inputs and their sum. 5) Checking if two numbers are twin primes. 6) Converting an octal number to decimal. 7) Converting a decimal number to octal.

Uploaded by

bhslegion1498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Problem 1: C program to display prime numbers between two positive integers[lower to higher]

using function.

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <7> <40>] => 9;11;13;17;19;23;29;31;37
a) Only two integers will be given as input through command line arguments separated
by space.You may assume that the input integer(s) will be such that the input will not exceed the
largest storage possible of INT type of variables.

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => E
b) fraction [./a.out 3.4 60.8] => E
c) string [./a.out * zebra] => E
d) more/less than than two command line input integers [./a.out 10 50 86] => E
e) one command line argument [./a.out *] => E
f) [ <./a.out> <40> <7> ] => E
g) [ <./a.out> <-40> <-7> ] => E

3. OUTPUT:
a) Print expected result set of prime numbers separated by ';' to the STDOUT without
any other additional text. [2;3;5;7;9;11;13]
b) In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================

Problem 2: C program to check whether an input positive integer number can be expressed as
sum of 2 primes. (For Eg:7=2+5, 9=2+7, 52=9+43, 52=23+29)

Test Cases:
-----------
1. VALID INPUT: [<./a.out> <9>]
a) Only one integer value will be given as input through command line argument
separated by space.You may assume that the input integer(s) will be such that the input will not
exceed the largest storage possible of INT type of variables.

2-a. VALID INPUTS: an integer I, where 2 < I <= 100

2-b. INVALID INPUTS: print only 'E' for any invalid conditions
a) no commandline argument. [./a.out] => E
b) fraction [./a.out 3.4 60.8] => E
c) string [./a.out zebra] => E
d) more than than one command line input integers [./a.out 10 86] => E
e) one special command line argument [./a.out *] => E
f) negative [./a.out -4] => E
g) if not possible to express as sum or two primes then print => 'NO' only without any
space or any extra text.

3. OUTPUT:
a) Print expected valid/success output as like:
7 => print 'YES'
9 => print 'YES'
52 => print 'YES'
21 => print 'YES'

to the STDOUT without any other additional text & any space.

b) In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================

Problem 3: C program to check check for an input positive number if prime or armstrong, using
user defined function
(For Eg:7 => B, 13 => P, 59 => P, 153 => A, 64 => N)
N.B: if input is only prime print 'P'
if input is only armstrong print 'A'
if input is both prime & armstrong print 'B'
if input is only not a prime & armstrong print 'N'
for any errors print 'E' as error without any extra
text.
Test Cases:
-----------
1. VALID INPUT: [<./a.out> <9>]
a) Only one integer value will be given as input through command line argument
separated by space.You may assume that the input integer(s) will be such that the input will not
exceed the largest storage possible of INT type of variables.

2-a. VALID INPUTS:

2-b. INVALID INPUTS: print only 'E' for any invalid conditions
a) no commandline argument. [./a.out ] => E
b) fraction [./a.out 3.4 60.8] => E
c) string [./a.out asdfg] => E
d) more than than one command line input integers [./a.out 10 50] => E
e) one special command line argument [./a.out *] => E
f) negative [./a.out -7] => E

3. OUTPUT:
a) Print expected valid/success output as like:
for 7 => B
for 13 => P
for 59 => P
for 153 => A
for 64 => N
for -5.5 => E
for * => E

to the STDOUT without any other additional text without any space.

b) In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================

Problem 4: C program to display all prime numbers between two positive integers[lower to
higher] using function & their sum

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <7> <40>] => 9+11+13+17+19+23+29+31+37=189
a) Only two integers will be given as input through command line arguments separated
by space.You may assume that the input integer(s) will be such that the input will not exceed the
largest storage possible of INT type of variables.

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => E
b) fraction [./a.out 3.4 60.8] => E
c) string [./a.out * zebra] => E
d) more/less than than two command line input integers [./a.out 10 50 86] => E
e) one command line argument [./a.out *] => E
f) [ <./a.out> <40> <7> ] => E
g) [ <./a.out> <-40> <-7> ] => E

3. OUTPUT:
a) Print expected result set of prime numbers separated by '+' & end with '=' & followed
by total_of_them i.e. sum to the STDOUT without any other additional text and space.
[9+11+13+17+19+23+29+31+37=189]
b) In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================
Problem 5: Write a C program to check if a pair of two numbers are twin prime or not. (A twin
prime is a prime number that is either 2 less or 2 more than another prime number—for example,
either member of the twin prime pair (41, 43). In other words, a twin prime is a prime that has
a prime gap of two. i.e. 41+2=43 or 43-2=41 & both are prime individually, so 41 and 43 are
twin prime)
e.g. (3, 5), (5, 7), (11, 13), (17, 19), (29, 31), (41, 43), (59, 61), (71, 73), (101, 103)...

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <7> <9>] => N
[<./a.out> <5> <7>] => TWINPRIME
a) Only two integers will be given as input through command line arguments separated
by space.You may assume that the input integer(s) will be such that the input will not exceed the
largest storage possible of INT type of variables.

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => E
b) fraction [./a.out 3.4 60.8] => E
c) string [./a.out * zebra] => E
d) more/less than than two command line input integers [./a.out 10 50 86] => E
e) one command line argument [./a.out *] => E
f) [ <./a.out> <40> <7> ] => E
g) [ <./a.out> <-40> <-7> ] => E

3. OUTPUT:
In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================

Problem 6: Write a C program to convert an octal number to decimal number


e.g. otcal => decimal
0 0
1 1
5 5
7 7
8 E
29 E
10 8
11 9
-17 -15
18 E
117 79

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <10>] => 8
[<./a.out> <9> ] => E
[ <./a.out> <-40> ] => -32

a) Only one integer will be given as input through command line arguments separated
by space.You may assume that the input integer(s) will be such that the input will not exceed the
largest storage possible of INT type of variables.

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => E
b) fraction [./a.out 3.4 60.8] => E
c) string [./a.out *alisa] => E
d) more/less than than one command line input integer [./a.out 10 50 86] => E
e) one command line argument [./a.out *] => E
f) <./a.out> <-40> <-7> ] => E
g) [ <./a.out> <-4-0> ] => E

3. OUTPUT:
In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================

Problem 7: Write a C program to convert a decimal number to octal number


e.g. decimal => otcal
0 0
1 1
5 5
7 7
8 10
29 35
10 12
11 13
-15 -17

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <10>] => 12
[<./a.out> <9> ] => 11
[ <./a.out> <-32> ] => -40

a) Only one integer will be given as input through command line arguments separated
by space.You may assume that the input integer(s) will be such that the input will not exceed the
largest storage possible of INT type of variables.
2. INVALID INPUTS:
a) no commandline argument [./a.out] => E
b) fraction [./a.out 3.4] => E
c) string [./a.out *krishna] => E
d) more than one command line input integers [./a.out 10 50 86] => E
e) one command line argument [./a.out *10] => E
f) [ <./a.out> <10r> ] => E
g) [ <./a.out> <-3-2> ] => E

3. OUTPUT:
In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================

Problem 8: Write a C program to reverse a sentence using recursion.

e.g. input => output


"The quick brown fox." => .xof nworb kciuq
ehT
"SIR I'M IRIS" => SIRI M'I
RIS

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <"Hello how are you?">] => ?uoy era woh olleH
[<./a.out> <*krishna>] => anhsirk*

a) Only one sentence will given as input through one command line argument. More
than one command line input separated by space should be considered as an invalid input. e.g. as
follows:

2. INVALID INPUTS:
a) no commandline argument [./a.out] => E
b) strings [./a.out * krishna] => E
c) more than one command line inputs [./a.out 1a0 50 86] => E
d) more than one command line arguments [./a.out & 10] => E

3. OUTPUT:
In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.
=====================================================================
========================

Problem 9: Write a C program to reverse a sentence using recursion.

e.g. input => output


"The quick brown fox." => .xof nworb kciuq
ehT
"SIR I'M IRIS" => SIRI M'I
RIS

Test Cases:
-----------
1. VALID INPUTS: [<./a.out> <"Hello how are you?">] => ?uoy era woh olleH
[<./a.out> <*krishna>] => anhsirk*

a) Only one sentence will given as input through one command line argument. More
than one command line input separated by space should be considered as an invalid input. e.g. as
follows:

2. INVALID INPUTS:
a) no commandline argument [./a.out] => E
b) strings [./a.out * krishna] => E
c) more than one command line inputs [./a.out 1a0 50 86] => E
d) more than one command line arguments [./a.out & 10] => E

3. OUTPUT:
In case of invalid input print 'E' to the STDOUT without any other additionl text and
terminate.

=====================================================================
========================
=====================================================================
==================

Problem 10: C program to find square root of a positive integers. Write the output to stdout
formatted as a floating point number rounded to EXACTLY 2 decimal precision WITHOUT any
other additional text. Scientific format(such as 1.00E+5) should NOT be used while printing the
output. You may assume that the inputs will be such that the output will not exceed the largest
possible real number that can be stored in a float
type variable.

Test Cases:
-----------
1. VALID INPUTS:
a) Only positive integers will be given as input through command line argument.
For Ex:- [/a.out 4] => 2.00

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) more than 1 command line arguments [./a.out 10 50] => ERROR
c) string [./a.out zebra] => ERROR
d) fraction [./a.out 3.4] => ERROR
e) negative number as input argument [./a.out -12] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as a floating point number rounded to
EXACTLY 2 decimal precision WITHOUT any other additional text. For example [./a.out 4] =>
2.00
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 11: C program to find sum of digits of a positive integers. Write the output to stdout
formatted as a integer number WITHOUT any other additional text. You may assume that the
inputs will be such that the output will not exceed the largest possible integer number that can be
stored in a int type variable.

Test Cases:
-----------
1. VALID INPUTS:
a) Only positive integers will be given as input through command line argument.You
may assume that the input integer will be such that the output will not exceed the largest storage
possible of INT type of variables.
For Ex:- [./a.out 2436] => 15

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) more than 1 command line arguments [./a.out 10 50] => ERROR
c) string [./a.out zebra] => ERROR
d) fraction [./a.out 3.4] => ERROR
e) negative number as input argument [./a.out -12] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as a Integer number WITHOUT any other
additional text.
For example [./a.out 2436] => 15
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 12: Write a C program to find the area of a circle given the diameter. The value
diameter is positive integer passed to the program as the first command line parameter. Write the
output to stdout formatted as a floating point number rounded to EXACTLY 2 decimal precision
WITHOUT any other additional text. Scientific format(such as 1.00E+5) should NOT be used
while printing the output. You may assume that the inputs will be such that the output will not
exceed the largest possible real number that can be stored in a float type variable.

Test Cases:
-----------
1. VALID INPUTS:
a) Only positive integer will be given as input through command line argument.
For Ex:- [/a.out 8] => 50.24

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) more than 1 command line arguments [./a.out 10 50] => ERROR
c) string [./a.out zebra] => ERROR
d) fraction [./a.out 3.4] => ERROR
e) negative number as input argument [./a.out -12] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as a floating point number rounded to
EXACTLY 2 decimal precision WITHOUT any other additional text. For example [./a.out 8] =>
50.24
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 13: C Program to find sum of series 1 + 1/2 + 1/3 + 1/4 +... + 1/n. The value n is
positive integer passed to the program as the first command line parameter. Write the output to
stdout formatted as a floating point number rounded to EXACTLY 2 decimal precision
WITHOUT any other additional text. Scientific format(such as 1.00E+5) should NOT be used
while printing the output. You may assume that the inputs will be such that the output will not
exceed the largest possible real number that can be stored in a float type variable.

Test Cases:
-----------
1. VALID INPUTS:
a) Only positive integer will be given as input through command line argument.
For Ex:- [/a.out 1] => 1.00
[/a.out 2] => 1.50
[/a.out 3] => 1.83
[/a.out 7] => 2.59

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) more than 1 command line arguments [./a.out 10 50] => ERROR
c) string [./a.out zebra] => ERROR
d) fraction [./a.out 3.4] => ERROR
e) negative number as input argument [./a.out -12] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as a floating point number rounded to
EXACTLY 2 decimal precision WITHOUT any other additional text. For example [./a.out 7] =>
2.59
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 14: C program to calculate difference between two time periods. The two time will be
passed to the program as the first and second command line parameters respectively in the
format as hour-minute-second. Write the output to stdout formatted as hour-minute-second
WITHOUT any other additional text.

Test Cases:
-----------
1. VALID INPUTS:
a) Only two time will be given as input through command line argument formatted as
hh-mm-ss.
For Ex:- [/a.out 8-15-39 15-1-20] => 7-14-19

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) 1 command line arguments [./a.out 7-15-54] => ERROR
c) string [./a.out zebra 15-1-20] =>
ERROR
[./a.out 7-15-54 zebra] =>
ERROR

3. OUTPUT:
a) Write the output to stdout formatted as hour-minute-second WITHOUT any other
additional text.
For example [/a.out 8-15-39 15-1-20] => 7-14-19
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 15: C program to add two complex numbers by passing structure to a function. All
inputs will be given as command line argument.
The first commandline argument is the real part of the first number.
The Second commandline argument is the imaginary part of the first number.
The Third commandline argument is the real part of the second number.
The Fourth commandline argument is the imaginary part of the second
number.
Test Cases:
-----------
1. VALID INPUTS:
a) Only integers will be given as input through command line argument.
For Ex:- [./a.out 14 3 5 18] => 19 21

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) If the number of command line argument is not equal to 4.
c) string [./a.out zebra 15 1 20] =>
ERROR
[./a.out 7 15 54 zebra] =>
ERROR

3. OUTPUT:
a) Write the output to stdout formatted as <real><space><imaginary> WITHOUT any
other additional text.
For example [./a.out 14 3 5 18] => 19 21
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================
Problem 16: C program to add two distances (in feet-inch) system using structure. All inputs will
be given as command line argument.
The first commandline argument is the feet part of the first distance.
The Second commandline argument is the inch part of the first distance.
The Third commandline argument is the feet part of the second distance.
The Fourth commandline argument is the inch part of the second distance.
Test Cases:
-----------
1. VALID INPUTS:
a) Only numbers(may be a floating point number) will be given as input through
command line argument.
For Ex:- [./a.out 14 3.1 5.2 16] => 19.2 21.1

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) If the number of command line argument is not equal to 4.
c) string [./a.out zebra 15 1 20] =>
ERROR
[./a.out 7 15 54 zebra] =>
ERROR

3. OUTPUT:
a) Write the output to stdout formatted as <feet><space><inch> WITHOUT any other
additional text.
For example [./a.out 14 3.1 5.2 16] => 19.2 21.1
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 17: C program to sort elements in lexicographical order. Write the output to stdout
formatted as word1;word2;word3... WITHOUT any other additional text.

Test Cases:
-----------
1. VALID INPUTS:
a) Only alphabets will be given as input through command line argument.
For Ex:- [./a.out Cat Dog Lion Bird Bear Deer
Tiger] =>Bear;Bird;Cat;Deer;Dog;Lion;Tiger
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) Any other Character other than Alphabet [./a.out Cat D$g] => ERROR
3. OUTPUT:
a) Write the output to stdout formatted as a Integer number WITHOUT any other
additional text.
For example [./a.out Cat Dog Lion Bird Bear Deer Tiger]
=>Bear;Bird;Cat;Deer;Dog;Lion;Tiger
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 18: C program to print reverse of a string using recursion.

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out Cat123] =>321taC
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one command line argument [./a.out Cat123 abc] =>
ERROR

3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text.
For example [./a.out Cat123] => 321taC
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 19: C program to remove characters from the first string which are present in the second
string. Two string will be given as input from commandline as first and second argument. You
need to remove characters from the first string which are present in the second string print it.

For ex : [./a.out morzilla mzi] =>orzlla


[./a.out morzilla123 la] =>morzi123

Test Cases:
-----------
1. VALID INPUTS:
a) Only two string will be given as input through command line argument.
For Ex:- [./a.out morzilla mzi] => orzlla
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than two command line argument [./a.out Cat123 abc axr] =>
ERROR

3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text.
For example [./a.out morzilla123 la] => morzi123
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 20: C program to print all the duplicates in the input string. One string will be given as
input from commandline.

For ex : [./a.out aabcdeeff1223] => aef2

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out aabcdeeff1223] => aef2
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one command line argument [./a.out aabcdeeff1223 gfdsa]
=> ERROR

3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text.
For example [./a.out aabcdeeff1223] => aef2
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 21:C program to remove all duplicates from the input string. One string will be given as
input from commandline.

For ex : [./a.out aabcdeeff1223] => bcd13


Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out aabcdeeff1223] => bcd13
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one command line argument [./a.out aabcdeeff1223 gfdsa]
=> ERROR

3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text.
For example [./a.out aabcdeeff1223] => bcd13
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 22:C program to return maximum occurring character in the input string. One string
will be given as input from commandline.

For ex : [./a.out aabbbbbcdeeff1223] => b

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out aabbbbbcdeeff1223] => b
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one command line argument [./a.out aabbbbbcdeeff1223
gfdsa] => ERROR

3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text.
For example [./a.out aabcdeeff1223] => b
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.
=====================================================================
========================

Problem 23: C Program to sort an array of names. Write the output to stdout formatted as
word1;word2;word3... WITHOUT any other additional text. Please note that only alphabets will
be given in input strings

Test Cases:
-----------
1. VALID INPUTS:
a) Only alphabets will be given as input through command line argument.
For Ex:- [./a.out Cat Dog Lion Bird Bear Deer
Tiger] =>Bear;Bird;Cat;Deer;Dog;Lion;Tiger
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) Any other Character other than Alphabet [./a.out Cat D$g] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as a Integer number WITHOUT any other
additional text.
For example [./a.out Cat Dog Lion Bird Bear Deer Tiger]
=>Bear;Bird;Cat;Deer;Dog;Lion;Tiger
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 24: C program to swap two Strings.

For ex : [./a.out Cat Dog] => Dog;Cat

Test Cases:
-----------
1. VALID INPUTS:
a) Only string will be given as input through command line argument.
For Ex:- [./a.out Cat Dog] =>Dog;Cat
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than two commandline argument [./a.out Cat Dog abc] =>
ERROR
3. OUTPUT:
a) Write the output to stdout formatted as <second_string><;><first_string>
WITHOUT any other additional text.
For example [./a.out Cat Dog] => Dog;Cat
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 25: C program to find length of a string without using strln(). You may assume that the
inputs will be such that the output will not exceed the largest possible integer number that can be
stored in a int type variable.

For ex : [./a.out Cat4325] => 7

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out Cat4325] => 7
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one commandline argument [./a.out Cat Dog] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as integer WITHOUT any other additional text.
For example [./a.out Cat4325] => 7
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
========================

Problem 26: C program to remove all character in a string except alphabets.

For ex : [./a.out Ca4322t] => Cat

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out Cat4325] => Cat
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one commandline argument [./a.out Cat Dog] => ERROR

3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text.
For example [./a.out Ca4322t] =>Cat
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
============================

Problem 27: C program to count number of vowels, consonant, digits and special characters in a
string. You may assume that the inputs will be such that the output will not exceed the largest
possible integer number that can be stored in a int type variable. Write the output as follwing
format.

For ex : [./a.out aab@bcdei12##246] => 4;4;5;3

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out aabbcdei12##@246] => 4;4;5;3
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one commandline argument [./a.out Cat526#@ Dog] =>
ERROR

3. OUTPUT:
a) Write the output to stdout formatted as follows without additional text.
For example [./a.out aabbcdei12##246] => 4;4;5;2
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
============================
Problem 28: C program to find frequency of a character in a string. You may assume that the
inputs will be such that the output will not exceed the largest possible integer number that can be
stored in a int type variable. Write the output as follwing format.

For ex : [./a.out hello] => h-1;e-1;l-2;0-1

Here 'h' comes first so the frequency of h is printed first. Then comes 'e'...etc. Please maintain
this order in the output.

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out hello] => h-1;e-1;l-2;0-1
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one commandline argument [./a.out Cat Dog] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as follows without additional text.
For example [./a.out hello] => h-1;e-1;l-2;0-1
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
==================================

Problem 29: C program to swap numbers in a cyclic fashion using call by reference.

Test Cases:
-----------
1. VALID INPUT:
a) Only 2 Integer will be given as input.You may assume that the input integer will be
such that the output will not exceed the largest possible integer that can be stored in an int type
variable.
For ex : [./a.out 423 5468] => 5468 423

2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) string [./a.out 435 asd] => ERROR
[./a.out fds 758] => ERROR

c) more than two command line arguments [./a.out 755 758 948] => ERROR
d) one command line argument [./a.out 758] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as follows without additional text.
For example [./a.out 423 5468] => 5468 423
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
====================================

Problem 30: C program to copy string without using strcpy().


For ex : [./a.out adgjl] => adgjl

Test Cases:
-----------
1. VALID INPUTS:
a) Only one string will be given as input through command line argument.
For Ex:- [./a.out adgjl] => adgjl
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) More than one commandline argument [./a.out adgjl Dog] =>
ERROR

3. OUTPUT:
a) Write the output to stdout formatted as follows without additional text.
For example [./a.out adgjl] => adgjl
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

=====================================================================
============================

Problem 31: C program to concatenate two strings.


For ex : [./a.out adgjl qwerty] =>adgjlqwerty

Test Cases:
-----------
1. VALID INPUTS:
a) Only two string will be given as input through command line argument.
For Ex:- [./a.out "adgjl 123" ""] => adgjl 123
[./a.out "super" " star"] =>
super star
[./a.out "* adgjl 123" ""] => *
adgjl 123
2. INVALID INPUTS:
a) no commandline argument. [./a.out] => ERROR
b) one commandline argument [./a.out Dog] => ERROR
c) More than two commandline argument [./a.out adgjl Dog hgfd] => ERROR

3. OUTPUT:
a) Write the output to stdout formatted as follows without additional text.
For example [./a.out adgjl qwerty] =>adgjlqwerty
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl
text and terminate.

You might also like