0% found this document useful (0 votes)
23 views34 pages

Rupakk

Uploaded by

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

Rupakk

Uploaded by

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

MANAV RACHNA UNIVERSITY, FARIDABAD

Department of Computer Science & Technology

Name: Rupak Bhardwaj

Roll. No: 2K24CSUN01128

Course: B.Tech. CSE Semester: I

Subject: Programming for Problem solving using C

WEEK-1
LAB: 01

Course Outcomes:CSH102C.1: To demonstrate programming skills for


solving elementary problems.

Blooms Taxonomy Level: BT1, BT2

Learning Objective: Students will be able to handle different data types,


variables, C operators, and formulate C expressions.
1.Write a program in C to print “Welcome to Manav Rachna”.

2.WAP in C to read and display an integer number,real number and character .


3.WAP in C that print the result of addition of two number.

4.WAP in C to read a character and display it’s ASCII Value.

5.WAP in C to find the size of int,float double and char variable.(Use %lu or %zu as well as
sizeof(variable) function.
6.WAP in C to calculate the average of two number given by the user.

LAB: 02

Course Outcomes:CSH102C.1: To demonstrate programming skills for


solving elementary problems.

Blooms Taxonomy Level: BT1, BT2,

Learning Objective: Students will be able to handle different data types,


variables, C operators, and formulate C expressions.
1. WAP in C to subtract, multiply ,divide and modulo of two integer numbers taken as
an input from the user.
2. WAP in C to subtract, multiply ,divide and modulo of two real numbers taken as an input from the
user.

3. WAP in C to calculate area of rectangle from the user input length and breadth.
4.WAP in C to calculate area of circle for the user input radius. Take the value of pi a constant i.e
3.14.(const float pi=3.14)

5.Write a program in C to swap two numbers using a temporary variable.

6.Write a program in C to swap two numbers without using a temporary variable.


LAB: 03

Course Outcomes:CSH102C.1: To demonstrate programming skills for


solving elementary problems.

Blooms Taxonomy Level: BT1, BT2

Learning Objective: Aim: Students will be able to handle to


implement and analyze basic concepts based on decision
statements used in C programming language
1.Write a program in C to determine whether a person is eligible to vote or not based on his
age.

2. Write a program in C to find whether the given number is even or odd.

3.Write a program to accept 2 numbers. Calculate the difference between the two values. If
the difference is equal to any of the values entered, then display the following message:
Difference is equal to value If the difference is not equal to any of the values entered,
display the following message: Difference is not equal to any of the values entered
4.Write a program to find whether a given year is a leap year or not.

LAB: 04
Course Outcomes:CSH102C.1: To demonstrate programming skills for solving elementary
problems.
Blooms Taxonomy Level: BT1, BT2,BT3
Learning Objective: Aim: Students will be able to handle to implement and analyze basic
concepts based on decision statements used in C programming language

1.Declare two variables x and y. Assign values to these variables. Number x should be
printed only if it is less than 2000 or greater than 3000, and number y should be printed only
if it is between 100 and 500.
2.Write a program to print the greatest of two numbers using conditional operators.

3.Write a program which displays the following output on the basis of inputted Mode Of
Payment and Tuition fees. Mode of payment can be 1, 2 or 3.
Mode Action
1 - Cash 10% Discount
2 - Two-Installment 5% Interest
3 - Three-Installment 10% Interest
Sample Outputs:
Enter Your Tuition Fee: 20000
Choose Mode of Payment: 1
The Amount of Payment: Rs. 18000
Enter Your Tuition Fee: 20000
Choose Mode of Payment: 2
The Amount of Payment: Two installments of Rs.10500 each
Enter Your Tuition Fee: 20000
Choose Mode of Payment: 3
The Amount of Payment: Three installments of Rs.7333.33 each
4.Write a program to accept the three sides of a triangle and determine whether they form a
valid triangle.

LAB: 05
Course Outcomes:CSH102C.1: To demonstrate programming skills for solving elementary
problems.
Blooms Taxonomy Level: BT1, BT2, BT3
Learning Objective: Students will be able to implement and analyze basic concepts based
on decision statements using nested-if else in C programming language.

1. Using nested if else statements, write a C program to find the largest of three numbers.
2. Triangle Type Determination
Question: Write a C program that takes the lengths of three sides of a triangle as input and
determines if the triangle is:
⦁ Equilateral (all sides equal)
⦁ Isosceles (two sides equal)
⦁ Scalene (all sides different)
⦁ Not a triangle (if the sum of any two sides is not greater than the third side)

3. Simple Calculator
Question: Write a C program that simulates a simple calculator. The program should take
two integers and a character (+, -, *, /, %) as input and output the result of the operation. If
the operator is invalid, print an error message.
4. Discount Based on Membership and Purchase Amount

Question: A store gives discounts based on membership status and the amount spent.
Members spending over Rs.100 get a 10% discount, non-members spending over Rs.150
get a 5% discount, and all others get no discount.

5. Leap Year Checker


Question: Write a C program that takes a year as input and determines whether it is a leap
year. A year is a leap year if:
⦁ It is divisible by 4, and
⦁ It is not divisible by 100, unless it is also divisible by 400.
LAB: 06
Course Outcomes:CSH102C.1: To demonstrate programming skills for solving elementary
problems.
Blooms Taxonomy Level: BT1, BT2, BT3,
Learning Objective: Students will be able to implement and analyze basic concepts based
on decision statements using switch statement used in C programming language.

1. Vowel or Consonant
Question: Write a C program that takes a single character as input and uses a switch
statement to determine if the character is a vowel (a, e, i, o, u) or a consonant. Handle both
uppercase and lowercase letters.

2. Days of the Week


Question: Write a C program that takes an integer input (1-7) and prints the corresponding
day of the week. The integer 1 corresponds to "Sunday", 2 to "Monday", and so on. If the
input is outside this range, print "Invalid input".
3. Simple Calculator
Question: Write a C program that simulates a simple calculator. The program should take
two integers and a character (+, -, *, /, %) as input and output the result of the operation. If
the operator is invalid, print an error message.

4. Grade Classification
Question: Write a C program that takes an integer input representing a student's score and
prints the corresponding grade based on the following scale:
⦁ 90-100: A
⦁ 80-89: B
⦁ 70-79: C
⦁ 60-69: D
⦁ 0-59: F
5. Temperature Rating
Question: Write a C program that takes a temperature in Celsius and provides a description
based on the temperature:
⦁ Below 0°C: Freezing
⦁ 0°C to 10°C: Cold
⦁ 11°C to 20°C: Cool
⦁ 21°C to 30°C: Warm
⦁ Above 30°C: Hot

LAB: 07
Course Outcomes:CSH102C.1: To demonstrate programming skills for solving elementary
problems.
Blooms Taxonomy Level: BT1, BT2, BT3
Learning Objective: Students will be able to handle to implement and analyze basic
concepts based on decision statements using while loopin C programming language

1. Write a C program that calculates the sum of all natural numbers up to a given number n
using a while loop. The program should take an integer input n and print the sum
2.Write a C program that calculates the factorial of a given non-negative integer n using a
while loop. The program should take an integer input n and print the factorial.

3.Write a C program that prints the Fibonacci series up to a given number n using a while
loop. The program should take an integer input n and print the Fibonacci series up to n.

4. Write a C program that prints the first n multiples of a given number k using a while loop.
The program should take integer inputs n (number of multiples) and k (the number to be
multiplied) and print the multiples.
5. Write a C program to print all alphabets from a to z. - using while loop.

LAB: 08
Course Outcomes:CSH102C.1: To demonstrate programming skills for solving elementary
problems.
Blooms Taxonomy Level: BT2,BT3
Learning Objective: Aim: Students will be able to handle to implement and analyze basic
concepts based on decision statements using while loop in C programming language.

1.Write a C program that counts the number of digits in a given integer using a while loop.
The program should take an integer input and print the count of its digits
2. Write a C program that reverses the digits of a given integer using a while loop. The
program should take an integer input and print the reversed number.

3. Write a C program to check whether a number is palindrome or not.

Lab-9
Q1. Write a C program to print numbers from 1 to 10 and 10 to 1 using a do-while loop.

Q2. Write a C program that prompts the user to input a series of integers until the user stops by
entering 0 using a do-while loop. Calculate and print the sum of all positive integers entered.
Q3. Write a C program that calculates the sum of even and odd numbers from 1 to 50 using do-while
loops

Q4. Write a C program that prompts the user to enter a series of numbers until they input a negative
number. Calculate and print the sum of all entered numbers using a do-while loop

LAB-10
Q1. Write a C program to compute the sum of the first 10 natural numbers

Q2. Write a program in C to read 10 numbers from the keyboard and find their sum and
average.
Q3. Write a program in C to display the cube of the number up to an integer.

Q4. Write a program in C to display the multiplication table for a given integer.

LAB-11
Q1. Write a program to make pattern like below:
Q2.write a program to make the Right Half Pyramid Pattern like below:

Q3.write a programs to make the Left Half Pyramid Pattern


LAB: 12
Q1. Write a program to make a half pyramid Pattern of Numbers
1
22
333
4444
55555

Q2.write a program to print continuous character patterns using a C program.


A
BC
DEF
GHIJ
KLMNO
Q3. Write a program to print the pattern of numbers in the following manner using for loop
1
232
34543
4567654
567898765

LAB-13
1. Write a program in C to find the reverse of a number using a function.
2. Write a program in C to check if a number input by the user is an Armstrong number
using a function.

3. Write a program in C to find the power of a number using a function (do not use the
inbuilt function pow ())

4. Write a program in C to read and display the elements of an array using a function.
5. Write a program in C to get the largest element of an array using a function.

LAB: 14
1. Write a program in C to count the number of digits in a given number using recursion.
2. Write a program in C to find the power of a number without using recursion.

3. WAP in C to calculate the factorial of a number using recursion.

4. Write a program in C to find the gcd of two numbers using recursion.


LAB-15

1. Write a program in C to read and display n numbers using an array.

2. Write a program in C to read n number of values in an array and display the array
in the reverse order.

3. Write a Program in C to find the sum of all elements of an array.


4. Write a program in C to find the largest number in an array given by the user.

5. Write a program in C to find the smallest element in an array.

6. Write a Program in C to search an element in an array using Linear search.


LAB-16
1. Write a program in C for a 2D array of size 3x3 and print the matrix.

2. Write a program in C for adding two matrices of the same size.

3. Write a program in C for the subtraction of two matrices.


4. Write a program in C for the multiplication of two square matrices.

5. Write a program in C to find the transpose of a given matrix.

6. Write a program in C to find the sum of rows and columns of a matrix.


7. Write a program in C to calculate the determinant of a 3 x 3 matrix.

LAB-17
Q1. Write a C code to swap two numbers using call by reference.

Q2. Write a C program to demonstrate the use of pointers


Q3. Write a C function that copies one string to another using pointers.

Q4. Write a program in C to access the elements of array without using its index

Q5. Implement bubble sorting algorithms using pointers.

LAB-18

Q1. Program to calculate the length of a string without using built-in functions.
Q2. Program to copy one string to another without using strcpy().

Q3. Program to concatenate two strings manually.

Q4. Program to compare two strings lexicographically without using strcmp().

Q5. Program to check if a given string is a palindrome.


Q6. Program to reverse a string in place.

Q7. Program to count the frequency of each character in a string.

Q8. Program to search for a substring within a string and return its position.

Q9. Program to count the number of vowels and consonants in a string.


Q10. Program to tokenize a string based on a delimiter (like spaces or commas).

You might also like