C Programs With Test Cases (Set 2)
C Programs With Test Cases (Set 2)
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.
2. INVALID INPUTS:
a) no commandline argument.
b) fraction
c) string
3. OUTPUT:
a) Print only the result of the addition to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
========
Test Cases:
-----------
1. VALID INPUT:
a) Only 2 floating point number will be given as input.You may assume that the input number
will be such that the output will not exceed the largest possible floating point number that can be stored
in an float type variable.
2. INVALID INPUTS:
a) no commandline argument.
c) string
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. Scientific format(such as 1.00E+5)
should NOT be used while printing the output.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
===============
1.OUTPUT:
a) Write the size of int, float, double and char to the STDOUT seperated by a space without any
other additional text.
=====================================================================================
===============
Test Cases:
-----------
1. VALID INPUT:
a) -5
b) fraction
c) string
3. OUTPUT:
a) If the number is even print 'EVEN' to the STDOUT without any other additional text.
b) If the number is 'ODD' to the STDOUT without any other additional text and terminate.
c) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
==================
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) Numbers
3. OUTPUT:
a) If the chracter is vowel print 'VOWEL' to the STDOUT without any other additional text.
b) If the character is consonant print 'CONSONANT' to the STDOUT without any other additional
text and terminate.
c) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=================
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
b) string
3. OUTPUT:
a) Print only the highest number to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=================
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) Print only the ASCII value to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
========================
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
3. OUTPUT:
a) If it is alphabet print 'Y' to the STDOUT without any other additional text.
b) If it is not alphabet print 'N' to the STDOUT without any other additional text.
c) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=========
Test Cases:
-----------
1. VALID INPUT:
b) string
3. OUTPUT:
a) Print only the highest number to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=========
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
b) fraction
c) string
3. OUTPUT:
a) If the number is even print 'EVEN' to the STDOUT without any other additional text.
b) If the number is 'ODD' to the STDOUT without any other additional text and terminate.
c) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
======
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
c) string
3. OUTPUT:
a) If the number is Positive print 'POSITIVE' to the STDOUT without any other additional text.
b) If the number is 'NEGATIVE' to the STDOUT without any other additional text and terminate.
c) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=====
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
b) fraction
c) string
3. OUTPUT:
a) Print only the sum to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=====
If the input is 9 OUTPUT will be like follows without any other additional text.
9*1=9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90
=================================================================================
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
b) fraction
c) string
3. OUTPUT:
a) Print only the terms seperated by a space to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
================================================================================
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
c) string
3. OUTPUT:
a) Print only the terms seperated by a space to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
======
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
c) string
3. OUTPUT:
a) Print GCD and LCM seperated by a space to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
======
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
3. OUTPUT:
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
=====
Test Cases:
-----------
1. VALID INPUT:
2. INVALID INPUTS:
a) -5
b) fraction
c) string
3. OUTPUT:
a) Print only the number of digits to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
Test Cases:
-----------
1. VALID INPUT:
a) Only one positive Integer(greater than 0) will be given as input.
2. INVALID INPUTS:
a) -5
b) fraction
c) string
3. OUTPUT:
a) Print only the reverse number to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additionl text and
terminate.
=====================================================================================
Test Cases:
-----------
1. VALID INPUT:
<dividend> <divisor>
2. INVALID INPUTS:
a) 5
b) fraction
c) string
d) 0 as divisor
b) For any invalid input or error print ERROR to the STDOUT without any other additional text and
terminate.
=====================================================================================
Test Cases:
-----------
=============================================================================
Problem 22: C program to make a simple calculator using switch case. Input numbers will be given as
integer(no floating point numbers) and in such a way that there will be no overflow in result.
Test Cases:
---------------
1. VALID INPUT: [format (infix notation only) i.e. 5 + 4; operand1(5) operator(+) operand2(4) without any
other extra text/characters. Output will be only 9. No extra characters/text.
e.g. ./a.out 9 * 10
OUTPUT: 90
2. INVALID INPUTS:
a) 7/0 => E
b) fraction
c) string
3. You should generate output as follows::
For any invalid input or error print E to the STDOUT without any other additional text and terminate.
===========================================================================