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

Practice Session Lab 2

The document outlines a series of programming exercises for a B.Tech course in Computer Programming and Fundamentals. It includes tasks related to operators, conditional statements, loops, and various algorithms such as calculating interest, finding prime numbers, and converting number systems. The exercises aim to enhance students' coding skills in C programming through practical implementation.

Uploaded by

Vagisha Yadav
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 views4 pages

Practice Session Lab 2

The document outlines a series of programming exercises for a B.Tech course in Computer Programming and Fundamentals. It includes tasks related to operators, conditional statements, loops, and various algorithms such as calculating interest, finding prime numbers, and converting number systems. The exercises aim to enhance students' coding skills in C programming through practical implementation.

Uploaded by

Vagisha Yadav
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/ 4

Practice Session Lab. – 2 [B.Tech.

]
Computer Programming and Fundamentals [Paper – 5]
Session Topic: Operators, Conditional Statement and Loop

1. Write a program to take input of name, rollno and marks obtained by a student in 4 subjects of
100 marks each and display the name, rollno with percentage score secured.
2. Write a program to calculate simple and compound interest.
3. Write a program to swap values of two variables with and without using third variable.
4. Write a program to display the size of every data type using “sizeof” operator.
5. Write a program to illustrate the use of unary prefix and postfix increment and decrement
operators.
6. Write a program to input two numbers and display the maximum number.
7. Write a program to find the largest of three numbers using ternary operators.
8. Write a program to find the roots of quadratic equation.
9. Write a program to print whether a given number is even or odd.
10. Write a Program to Check Whether a Number is Prime or not.
11. Write a program to find the largest and smallest among three entered numbers and also
display whether the identified largest/smallest number is even or odd.
12. Write a program to compute grade of students using if else adder. The grades are assigned as
followed:
Marks Grade
marks< 50 F
50≤ marks < 60 C
60≤ marks <70 B
70≤ marks <80 B+
80≤ marks <90 A
90≤ marks ≤ 100 A+
13. Write a program to check whether the entered year is leap year or not (a year is leap if it is
divisible by 4 and divisible by 100 or 400.)
14. Write a program to find the factorial of a number.
15. Write a program to check number is Armstrong or not. (Hint: A number is Armstrong if the
sum of cubes of individual digits of a number is equal to the number itself).
16. Write a program to find whether a character is consonant or vowel using switch statement.
17. Write a program to print day name using switch case.
18. Write a program to determine whether the input character is capital or small letter, digits or
special symbol.
19. Write a program to check whether a date is valid or not.
20. Write a program to check whether a number is positive, negative or zero using switch case.
21. Write a program to print positive integers from 1 to 10.
22. Write a program to count number of digits in a given integer.
23. Write a program to reverse a given integer.
24. Write a program to print number in reverse order with a difference of 2.
25. Write a program to print the sum of digits of a number using for loop.
26. Write a program to check whether a number is Palindrome or not.
27. Write a program to generate Fibonacci series.
28. If a four-digit number is input through the keyboard, write a program to obtain the sum of the
first and last digit of this number.
29. Write a program to find GCD (greatest common divisor or HCF) and LCM (least common
multiple) of two numbers.
30. Write a program to display the following pattern.
* ***** *
** **** ***
*** *** *****
**** ** *******
***** * *********

********* 1 A
******* 121 ABA
***** 12321 ABCBA
*** 1234321 ABCDCBA
* 123454321 ABCDEDCBA

1 ********* **********
123 **** **** *
12345 *** *** *
123 ** ** *
1 * * ***************

31. Write a C Program to accept product name, quantity, price compute bill amount and discount
based on following criteria.
IF Bill amount > 1000, rate of discount is 10%.
If bill amount > 2000, rate if discount is 15%

Display output in following format;

***************Welcome to ABC Hyper Market********

Item Name Qty Rate Amount


Basmati Rice 8 100 800
Aata 5 50 250
Millet 8 70 56
Milk 6 67 402
---------------------------------------------------------------
Total Items 27 - 1508
Discount Amt: 40
Total Bill Amount After discount Rs. 1468

****************Thank ’U’ Visit Again****************

32. Write a program to accept Employee Name, Designation, Basic Salary compute and display
Payslip in the following format.
Payslip Name: Designation: Basic:
HRA: DA: CA:
Gross Salary: PF: ESI:
Net Salary:

Where HRA is 20% on Basic Salary, DA is 50% on Basic Salary, CA is 10% on Basic Salary,
PF is 12% on Basic Salary and ESI is 5% on Basic Salary.

33. Write a C program to print all natural numbers from 1 to n. – using while loop
34. Write a C program to print all natural numbers in reverse (from n to 1). – using while
loop
35. Write a C program to print all alphabets from a to z. – using while loop
36. Write a C program to print all even numbers between 1 to 100. – using while loop
37. Write a C program to print all odd number between 1 to 100.
38. Write a C program to find sum of all natural numbers between 1 to n.
39. Write a C program to find sum of all even numbers between 1 to n.
40. Write a C program to find sum of all odd numbers between 1 to n.
41. Write a C program to print multiplication table of any number.
42. Write a C program to count number of digits in a number.
43. Write a C program to find first and last digit of a number.
44. Write a C program to find sum of first and last digit of a number.
45. Write a C program to swap first and last digits of a number.
46. Write a C program to calculate sum of digits of a number.
47. Write a C program to calculate product of digits of a number.
48. Write a C program to enter a number and print its reverse.
49. Write a C program to check whether a number is palindrome or not.
50. Write a C program to find frequency of each digit in a given integer.
51. Write a C program to enter a number and print it in words.
52. Write a C program to print all ASCII character with their values.
53. Write a C program to find power of a number using for loop.
54. Write a C program to find all factors of a number.
55. Write a C program to calculate factorial of a number.
56. Write a C program to find HCF (GCD) of two numbers.
57. Write a C program to find LCM of two numbers.
58. Write a C program to check whether a number is Prime number or not.
59. Write a C program to print all Prime numbers between 1 to n.
60. Write a C program to find sum of all prime numbers between 1 to n.
61. Write a C program to find all prime factors of a number.
62. Write a C program to check whether a number is Armstrong number or not.
63. Write a C program to print all Armstrong numbers between 1 to n.
64. Write a C program to check whether a number is Perfect number or not.
65. Write a C program to print all Perfect numbers between 1 to n.
66. Write a C program to check whether a number is Strong number or not.
67. Write a C program to print all Strong numbers between 1 to n.
68. Write a C program to print Fibonacci series up to n terms.
69. Write a C program to find one’s complement of a binary number.
70. Write a C program to find two’s complement of a binary number.
71. Write a C program to convert Binary to Octal number system.
72. Write a C program to convert Binary to Decimal number system.
73. Write a C program to convert Binary to Hexadecimal number system.
74. Write a C program to convert Octal to Binary number system.
75. Write a C program to convert Octal to Decimal number system.
76. Write a C program to convert Octal to Hexadecimal number system.
77. Write a C program to convert Decimal to Binary number system.
78. Write a C program to convert Decimal to Octal number system.
79. Write a C program to convert Decimal to Hexadecimal number system.
80. Write a C program to convert Hexadecimal to Binary number system.
81. Write a C program to convert Hexadecimal to Octal number system.
82. Write a C program to convert Hexadecimal to Decimal number system
83. Write a C program to print Pascal triangle upto n rows.
84. Star pattern programs – Write a C program to print the given star patterns.
85. Number pattern programs – Write a C program to print the given number patterns.

You might also like