Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programming for Problem Solving using C: Lab Experiments and Quizzes, Lecture notes of Applied Mathematics

A comprehensive set of lab experiments and quizzes designed to introduce students to the fundamental concepts of computer programming using the c programming language. It covers topics such as basic syntax, data types, operators, control flow, functions, arrays, and pointers. Detailed instructions, code examples, and quiz questions with answers, making it a valuable resource for students learning c programming.

Typology: Lecture notes

2024/2025

Uploaded on 03/06/2025

jaya-singh-4
jaya-singh-4 🇮🇳

1 document

1 / 48

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PROGRAMMING FOR PROBLEM SOLVING USING C (CSE-101P)
DEPARTMENT OF APPLIED SCIENCE & HUMANITIES
DRONACHARYA COLLEGE OF ENGINEERING
KHENTAWAS, FARRUKH NAGAR, GURUGRAM (HARYANA)
LABORATORY MANUAL
B.Tech. Semester- I
PROGRAMMING FOR PROBLEM SOLVING USING C
Subject code: CSE-101P
Prepared by:
Checked by:
Approved by:
Prof. Sakshi Ahuja
Prof. Megha Goel
Name : Prof. (Dr.) Isha Malhotra
Sign.: …………………….
Sign.: ………………….
Sign.: ………………….
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30

Partial preview of the text

Download Programming for Problem Solving using C: Lab Experiments and Quizzes and more Lecture notes Applied Mathematics in PDF only on Docsity!

DEPARTMENT OF APPLIED SCIENCE & HUMANITIES

DRONACHARYA COLLEGE OF ENGINEERING KHENTAWAS, FARRUKH NAGAR, GURUGRAM (HARYANA) LABORATORY MANUAL B.Tech. Semester- I

PROGRAMMING FOR PROBLEM SOLVING USING C

Subject code: CSE-101P

Prepared by: Checked by: Approved by:

Prof. Sakshi Ahuja Prof. Megha Goel Name : Prof. (Dr.) Isha Malhotra

Sign.: ……………………. Sign.: …………………. Sign.: ………………….

Table of Contents

  1. Vision and Mission of the Institute
  2. Vision and Mission of the Department
  3. Program Educational Objectives (PEOs)
  4. Program Outcomes (POs)
  5. Program Specific Outcomes (PSOs)
  6. University Syllabus
  7. Course Outcomes (COs)
  8. Course Overview
  9. List of Experiments
  10. DOs and DON’Ts
  11. General Safety Precautions
  12. Guidelines for students for report preparation
  13. Lab assessment criteria
  14. Lab Experiments

Vision and Mission of the Department

Vision:

To lay a strong foundation for the first year students of the engineering discipline in the area of Applied Sciences and Humanities with a view to make them capable of innovating and inventing engineering solutions and also develop students as capable and responsible citizens of our nation.

Mission:

  • To build strong fundamental knowledge and ability for application in students and make them capable to apply knowledge of mathematics and science to the solution of complex engineering problems.
  • To impart knowledge, leading to understanding between engineering and other core areas of Applied Sciences and Humanities.
  • To provide students the basic tools of analysis, as well as the knowledge of the principles on which engineering is based.
  • To strive to inculcate the scientific temper and the spirit of enquiry in the students.
  • To make students achieve a superior level in communication and presentation skills.
  • To foster values and ethics and make students responsible citizens of India.
  • To pursue inter-disciplinary research for the larger good of the society.

Program Educational Objectives (PEOs) PEO1: To provide students with a sound knowledge of mathematical, scientific and engineering fundamentals required to solve real world problems. PEO2: To develop research oriented analytical ability among students and to prepare them for making technical contribution to the society. PEO3: To develop in students the ability to apply state-of-the–art tools and techniques for designing software products to meet the needs of Industry with dueconsideration for environment friendly and sustainable development. PEO4: To prepare students with effective communication skills, professional ethics and managerial skills. PEO5: To prepare students with the ability to upgrade their skills and knowledgefor life-long learning.

Program Specific Outcomes (PSOs) PSO1: Analyze, identify and clearly define a problem for solving user needs by selecting, creating and evaluating a computer-based system through an effective project plan. PSO2: Design, implement and evaluate processes, components and/or programs using modern techniques, skills and tools of core Information Technologies to effectively integrate secure IT- based solutions into the user environment. PSO3: Develop impactful IT solutions by using research-based knowledge and research methods in the fields of integration, interface issues, security & assurance and implementation.

University Syllabus

  1. WAP to display “Hello World”.
  2. WAP to Print additional, subtraction, multiplication, and division of two numbers.
  3. WAP to swap two numbers using a third variable.
  4. WAP to calculate Simple Interest.
  5. WAP to find whether a given number is even or odd.
  6. WAP to calculate the sum of first n natural numbers
  7. WAP to design a simple calculator using Switch case.
  8. WAP to display Fibonacci Series.
  9. WAP to print sum of diagonal elements of a matrix.
  10. WAP to swap 2 numbers by creating a function using call by value.

Course Overview Programming for Problem Solving using C is a course designed to introduce students to the fundamental concepts of computer programming using the C programming language. The course focuses on developing problem-solving skills through the application of programming techniques and algorithms. Throughout the course, students will learn how to analyze problems, design solutions, and implement them using the C programming language. They will gain a solid understanding of programming concepts such as variables, data types, control structures, loops, functions, and arrays. Additionally, students will be introduced to essential algorithms and techniques used in solving common programming problems.

List of Experiments mapped with COs S. No. List of experiments Course Outcomes Page No. 1 WAP to display “Hello World”.^ CO1^1 -^3 2 WAP to Print additional, subtraction, multiplication, and division of two numbers

CO1 4 - 6

3 WAP to^ swap two numbers using a third variable^ CO2^7 -^9 4 WAP to calculate Simple Interest.^ CO2^10 -^12 5 WAP to find whether a given number is even or odd.

CO3 13 - 15

6 WAP to calculate the sum of first n natural numbers

CO3 16 - 18

WAP to design a simple calculator using Switch case.

CO3 19 - 22

WAP to display Fibonacci Series. CO4 23 - 25 9 WAP to print sum of diagonal elements of a matrix.

CO5 26 - 28

10 WAP to swap 2 numbers by creating a function using call by value.

CO5 29 - 31

General Safety Precautions Precautions (In case of Injury or Electric Shock)

  1. To break the victim with live electric source, use an insulator such as fire wood or plastic to break the contact. Do not touch the victim with bare hands to avoid the risk of electrifying yourself.
  2. Unplug the risk of faulty equipment. If main circuit breaker is accessible, turn the circuit off.
  3. If the victim is unconscious, start resuscitation immediately, use your hands to press the chest in and out to continue breathing function. Use mouth-to-mouth resuscitation if necessary.
  4. Immediately call medical emergency and security. Remember! Time is critical; be best. Precautions (In case of Fire)
  5. Turn the equipment off. If power switch is not immediately accessible, take plug off.
  6. If fire continues, try to curb the fire, if possible, by using the fire extinguisher or by covering it with a heavy cloth, if possible, isolate the burning equipment from the other surrounding equipment.
  7. Sound the fire alarm by activating the nearest alarm switch located in the hallway.
  8. Call security and emergency department immediately: Emergency: Reception Security: Main Gate

Guidelines to students for report preparation All students are required to maintain a record of the experiments conducted by them. Guidelines for its preparation are as follows: - 1) All files must contain a title page followed by an index page. The files will not be signed by the faculty without an entry in the index page.

  1. Student’s Name, Roll number and date of conduction of experiment must be written on all pages.
  2. For each experiment, the record must contain the following (i) Aim/Objective of the experiment (ii) Pre-experiment work (as given by the faculty) (iii) Lab assignment questions and their solutions (iv) Test Cases (if applicable to the course) (v) Results/ output Note:
  1. Students must bring their lab record along with them whenever they come for the lab.
  2. Students must ensure that their lab record is regularly evaluated.

LAB EXPERIMENTS

Department of Applied Science & Humanities 2022 - 23 1

LAB EXPERIMENT 1

OBJECTIVE:

WAP to display “Hello World”.

PRE-EXPERIMENT QUESTIONS:

Q1. When and Where C-language is developed? Q2. What is the use of printf() function in C Language?

ALGORITHIM TO DISPLAY “HELLO WORLD” IN C PROGRAM:

1. Start the program.

2. Include the necessary header files, such as <stdio.h>, at the beginning of the program.

3. Define the main () function with a return type of int.

4. Within the main () function, use the printf() function to output the string "Hello World" to the

console. The function call should look like: printf("Hello World");.

5. Return 0 at the end of the main () function to indicate successful execution of the program.

6. End the program.

Here's an example of how the complete program would look:

PROGRAM:

#include <stdio.h> #include <conio.h> int main() { printf("Hello World"); return 0; }

Department of Applied Science & Humanities 2022 - 23 3 return a value (if applicable) back to the caller of the function. It allows a function to pass a result or outcome back to the code that called it. Q5. What is the use of printf() statement? Ans: The printf() statement is a function in the C programming language (and other programming languages influenced by C) that is used to print formatted output to the console or standard output. It stands for "print formatted" and is part of the standard input/output library in C. Q6. What is #include? Ans: In C programming, the #include directive is a preprocessor directive that is used to include external files or libraries into your C program. It allows you to use code from other files or libraries in your program by "including" them at the specified location. Q7. What are header files? Ans: A C header file is a text file that contains pieces of code written in the C programming language. Q8. What are the functions included in #include<stdio.h>? Ans: The <stdio.h> header file contains function prototypes and definitions for functions like printf(), scanf(), fprintf(), and fscanf(), which are commonly used for input and output operations. By including this header file in your C program, you make these functions available for use. Q9. What are the functions included in #include<conio.h>? Ans: Following are some of the functions of the header file conio.h -

  1. clrscr()
  2. getch()
  3. getche()
  4. putch()
  5. cgets()
  6. cputs()
  7. cscanf()
  8. cprintf()
  9. kbhit()
  10. textcolor()
  11. textbackground()
  12. delline
  13. gotoxy
  14. wherex
  15. wherey

Department of Applied Science & Humanities 2022 - 23 4

LAB EXPERIMENT 2

OBJECTIVE

WAP to Print additional, subtraction, multiplication, and division of two numbers.

PRE-EXPERIMENT QUESTIONS:

1. What are the basic data types in C?

2. What is the range of value data type variable can hold?

BRIEF DISCUSSION AND EXPLANATION:

ALGORITHIM:
  1. Start the program.
  2. Declare two variables num1 and num2 to store the input numbers.
  3. Prompt the user to enter the first number and store it in num.
  4. Prompt the user to enter the second number and store it in num.
  5. Declare four variables: addition , subtraction , multiplication , and division.
  6. Perform addition by adding num1 and num2 , and store the result in addition.
  7. Perform subtraction by subtracting num2 from num1 , and store the result in subtraction.
  8. Perform multiplication by multiplying num1 and num2 , and store the result in multiplication.
  9. Perform division by dividing num1 by num2 , and store the result in division.
  10. Print the values of addition , subtraction , multiplication , and division.
  11. End the program. Here's an example of how the complete program would look: