Skip to content

Latest commit

 

History

History

2022_01_30_CClass-4

C Class 4

.. Previous Page

Class recording: Here

PPT: Here

January 30th, 2022

C language logo

Tasks

Offline

Warmup

  1. Write a program (WAP) to accept an year from the user and check whether it is a leap year or not. Rules to check leap year.
  2. Write a program with two integer variables a = 5 and b = 8. Swap the values of the two numbers by using a temporary variable such that the value of a is now 8 and the value of b is now 5.
  3. Do problem 2 without using a temporary variable.

Switch-case

  1. WAP to accept a number from 1 to 7 and display the corresponding day of the week.
  2. WAP to accept two numbers and a operator (+, -, *, /, %) from user and perform the operation on the two numbers as per the operator entered and display the result.
  3. Write a menu driven program to accept a choice from user and as per the choice perform the following operations:
    • Area of a circle
    • Area of a rectangle
    • Area of a triangle (Heron's formula)
    • Volume of a sphere
  4. WAP to acept an alphabet from user and display whether it is a vowel or consonant.
  5. Write a munu driven program to accept a choice from user and as per the choice perform the following operations:
    • Convert Decimal to Binary
    • Convert Binary to Decimal
    • Convert Decimal to Hexadecimal
    • Convert Hexadecimal to Decimal
    • Convert Decimal to Octal
    • Convert Octal to Decimal

Loops

  1. WAP to display all even numbers from 1 to 100.
  2. WAP to display all odd numbers between two number entered by user.
  3. WAP to print all alphabets from a to z.
  4. WAP to accept a number from user and display the factorial of that number.
  5. WAP to accept a number from user and display whether it is an Armstrong number or not.
  6. WAP to accept a number frm user and display its multiplication table.
  7. WAP to accept a number from user and display the number of digits in that number.
  8. WAP to accept a number from user and display the sum of digits in that number.
  9. WAP to accept a number from user and display the product of digits in that number.
  10. WAP to accept a number from user and display the reverse of that number.
  11. WAP to accept a number from user and display whether it is a palindrome or not.
  12. WAP to accept a number from user and display whether it is a prime number or not.
  13. WAP to display all prime numbers between 1 to 100.
  14. WAP to accept two numbers from user and display the Greatest Common Divisor (GCD) (or the Highest Common Factor (HCF)) of those two numbers.
  15. WAP to accept two numbers from user and display the Least common multiple (LCM) of those two numbers.
  16. WAP to accept two numbers from user and display the nCr of those two numbers.
  17. WAP to print numbers from 1 to 100 with their binary and octal representation.
  18. Print all letter combinations from AA to ZZ using a single for loop, i.e., AA, AB, AC, ..., BA, BB, BC, ..., ZZ.

Operator precedence

  1. Learn operator precedence in C (click on image to enlarge):

    C Operator precedence and associativity

    You can take help of this Mnemonic.

  2. Practice operator precedence questions from C in Depth book.

HackerRank:

  1. For Loop in C
  2. Sum of Digits of a Five Digit Number
  3. Read and do Bitwise Operators.

Quizzes

  1. If Else Statement Quiz in C
  2. Quiz on Increment and Decrement Operators in C

Happy Learning!

{% include disqus.html %}