C-Programming Lab

Exercise - 1

  1. Program to swap two numbers without using temporary variable and arithmetic operators.
  2. Program to check whether the number is even or odd without using arithmetic operators.
  3. Program to double the given number without using '*' operator.

Exercise - 2

  1. Program to find minimum number of denominations for given amount.
  2. Program to input basic salary of an employee and calculate its Gross salary according to following:
    • Basic Salary <= 10000 : HRA = 20%, DA = 80%
    • Basic Salary <= 20000 : HRA = 25%, DA = 90%
    • Basic Salary > 20000 : HRA = 30%, DA = 95%
  3. Given an integer, n, perform the following conditional actions:
    • If n is odd, print Weird
    • If n is even and in the inclusive range of 2 to 5, print Not Weird
    • If n is even and in the inclusive range of 6 to 20, print Weird
    • If n is even and greater than 20, print Not Weird

Exercise - 3

  1. Program to compute and display the sum of the following series up to n-terms:
    X - X/2 + X/3 - X/4 +…
  2. Program to compute and display the sum of the following series up to n-terms:
    (1*2)/(1+2) + (1*2*3)/(1+2+3) + … + (1*2*3*…*n)/(1+2+3+…+n)
  3. Program to find sum of digits of a given number until sum becomes single digit.

Exercise - 4

  1. Program to print pattern as shown in below.
    Sample Input
    5
    Sample Output
    1 0 0 0 1
    0 1 0 1 0
    0 0 1 0 0
    0 1 0 1 0
    1 0 0 0 1
  2. Program to print pattern as shown in sample output.
    Sample Input
    5
    Sample Output
    A
    ABA
    ABCBA
    ABCDCBA
    ABCDEDCBA
  3. Program that displays butterfly pattern as shown sample given below.
    Sample Input
    4
    Sample Output
    *            *
    **        **
    ***    ***
    ********
    ********
    ***    ***
    **        **
    *            *

Exercise - 5

  1. Program to count the frequency of each element of an array.
  2. Program to find duplicate element in k-distance. If found print "YES" otherwise "NO".
  3. Program for left rotate of array elements for k-times.

Exercise - 6

  1. Program to swap cases in the given String.
  2. Program to check whether given expression contains valid parenthesis or not.
  3. Program to implement Caesar Cipher.
    Note: Caesar Cipher is an encryption technique in cryptography. In this technique, we are given a text which we have to encrypt by shifting the characters by some fixed number of positions.