_PIC Lab Manual
_PIC Lab Manual
Programmers Concept
Programming in C
(312303)
Semester-II
( AI/ AN/ BD/ CM/ CO/ CW/ DS/ HA/ IF/ IH )
Maharashtra State
Certificate
Seal
of
Institutio
n
Following programme outcomes are expected to be achieved along with programme specific
outcomes through the practical’s of the course:
Basic and Discipline specific knowledge: Apply knowledge of basic mathematics, science
and engineering fundamentals and engineering specialization to solve engineering problems.
Problem analysis: Identify and analyse well-defined engineering problems using codified
standard methods.
Design/ development of solutions: Design solutions for well-defined technical problems and
assist with the design of systems components or processes to meet specified needs.
Engineering Tools, Experimentation and Testing: Apply modern engineering tools and
appropriate techniques to conduct standard tests and measurements.
Life-long learning: Ability to analyze individual needs and engage in updating in the context
of technological changes.
8
Implement minimum two C √
programs using Bitwise
Operators
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
9 √
Implement minimum two C
programs using simple If
statement and if. Else
statement.
10 √
Implement minimum two C
programs using nested If .else
statement and if.. else if ladder.
e.g _Write and execute the C program
to print the grade of students based on
percentage.
Grade: Distinction if per>=75
I. Practical Significance
This practical is useful for students to understand procedure of Installation of C
programming Environment.
VII. Exercise
1. Install the C compiler on the PC and write the steps.
2. Draw the notations of flowchart.
3. Write an algorithm and draw flowchart for the C program to read two numbers and
print those two numbers.
4. Write a program in C for Q.3.
VIII. Algortithm
2.
Turbo C/gcc
‘C’ Compiler
XII. Precautions
XIII. Conclusion (Action/ decision to be taken based on the interpretation of the results)
...................................................................................................................................................
...................................................................................................................................................
Weightage
Performance indicators
60%
Process related: 30 Marks
Debugging ability 20%
1.
Correctness of Program codes 30%
2.
Quality of output achieved(LLO mapped) 10%
3.
VII. Exercise
Write a program in C for:
1.Celsius to Fahrenheit conversion.
2.Area calculation of rectangle
3.Area calculation of circle with PI value constant and #define function.
VIII. Algorithm
2.
Turbo C/gcc
‘C’ Compiler
XII. Precautions
1. Handle computer system with care. '
2. Strictly follow the instructions for writing, compiling, and executing the program.
3. Start and Shutdown system with proper procedure.
4. Don't forget to include header file related to functions.
XIII. Conclusion (Action/ decision to be taken based on the interpretation of the results)
...................................................................................................................................................
...................................................................................................................................................
Practical No.5 Write well commented C programs using formatted Input/ Output statements.
I. Practical Significance
This practical is useful for students to use different format specifiers for different
data types. After the completion of this practical student will be able to use
formatted input output statements in program.
VII. Exercise
Write a program in ‘c’ to develop a code for following formatted structure:
Roll No XXXX
(upto 2 decimal places)
Percentage
DD/MM/YYYY
Date of Birth
Branch,College XXXXXXXXXXXXX
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
VIII. Algorithm
IX. Flowchart
XII. Precautions
1. Handle computer system with care.
2. Strictly follow the instructions for writing, compiling, and executing the program.
3. Start and shutdown system with proper procedure.
……………………………………………………………………………
……………………………………………………………………………
2. https://spoken-tutorial.org/tutorial-
search/?search_foss=C+and+Cpp&search language—English
I. Practical Significance
Students will be able to use relational and conditional operators in the C program.
II. Industry Outcomes
The aim of this course is to help students to attain the following industry identified outcomes
through various teaching and learning experiences:
Develop C programs that address issues with mathematic operations.
Operator Meaning
Less than
<
Greater than
>
<= Less than or equal to
Greater than or equal to
>=
== Equal to
Not equal to
!=
The Conditional Operator (?:) is an operator that takes three arguments. The first argument
is a comparison argument, the second is the result upon a true comparison, and the third is
the result upon a false comparison. If it helps you can think of the operator as a shortened
way of writing an if-else statement. It is often used to assign variables based on the result of
a comparison. When used correctly it can help increase the readability and reduce the number
of lines in your code.
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
VII. Exercise
1.Develop a program to print two numbers are equal or not.
2. Develop a program to print the largest of two numbers using conditional operator.
VIII. Algorithm
IX. Flowchart
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
I. Practical Significance
Students will be able to understand logical operators.
After completion of practical student will be able to use logical operators in C program.
VII. Exercise
Write a C program to:
1.Identify whether given number is Positive even, Positive odd, Negative even or
Negative odd.
2. Find the greatest/smallest number between the given 3 numbers.
VIII. Algorithm
Weightage
Performance indicators
60%
Process related: 30 Marks
Debugging ability 20%
1.
Correctness of Program codes 30%
2.
Quality of output achieved (LLO mapped) 10%
3.
40%
Product related: 20 Marks
Completion and submission of practical in time 20%
1.
Answer to sample questions 20%
2.
Total 50 Marks 100%
I. Practical Significance
Student will be able to understand use of switch case over if-else statement and will
solve given problem using switch statement.
II. Industry /Employer Expected Outcome
This practical is expected to develop the following skills as:
Develop ‘C’ programs that address issues of branching statements and looping statements.
Syntax of switch
Statement in C
switch(expression
)
{
case value1: statement_1;
break;
case value2: statement_2;
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
break;
case value_n: statement_n;
break;
default: default_statement;
}
VII. Exercise
1. Write a C program that reads the value in the range of 1 -12 and print the name of that
month and next month. Print error for any other value.
VIII. Algorithm
XII. Precautions
1. Handle computer system with care.
2. Strictly follow the instructions for writing, compiling, and executing the program.
3. Start and shutdown system with proper procedure.
4. Don’t forget to include header file related to functions.
5. Syntax for switch cases should be given properly.
6. The case condition must be constant, or some value that may be evaluated at time.
XIII. Conclusion (Action/ decision to be taken based on the interpretation of the results)
...................................................................................................................................................
...................................................................................................................................................
{
Int ch='a'+'b';
switch(ch)
{
case ‘a’ :
printf("You have entered a");
case 'b':
printf("\n You entered b");
case 'A':
printf("You have entered A");
case 'b'+'a':
printf("You have entered a & b");
}
return 0;
}
{
int check=2; Switch (check)
{
case1:
printf("D.W.Steyen") ;
case 2 :
printf("M.G.Johnson");
case 3:
printf("Mohammad Asif");
default:
printf("M.Muralidaran");
}
return 0;
}
4. Write a C program to print day of the week by taking number from 1 to 7 using switch
statement.
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
1. https://www.geeksforgeeks.org/c-switch-statement/
2. https://spoken-tu torial.org/ tutorial-search/?search_for=C++ and +Cpp
search_language
=English
3. https://www.prohramiz.com/c-programming/c-switch-case-statement
Weightage
Performance indicators
60%
Process related: 30 Marks
Debugging ability 20%
1.
Correctness of Program codes 30%
2.
Quality of output achieved (LLO mapped) 10%
3.
40%
Product related: 20 Marks
Completion and submission of practical in time 20%
1.
Answer to sample questions 20%
2.
Total 50 Marks 100%
Dated Sign of
Teacher
Marks obtained
Product Total
Related 35 50
Process
Related 10
Practical No 12: Write a C program to print English Calendar months as per given number
using switch statement.
.
I. Practical Significance
Students will be able to solve logical problems using switch statements and will
develop an ability to understand how multiple if -else statements can be replaced by
simple switch case.
Syntax: -
switch(expression)
case value-1:
block-1;
break;
case value-2:
block-2;
break;
……..
…….. default:
default-block;
break;
}
statement-x;
VII. Exercise
1. Write a C program to print English Calendar months as per
given number (eg : If input is 4 then print “April”) using
Switch statement.
2. Write a C program to Print days of week by taking number from 1 to 7.
VIII. Algorithm
IX. Flowchart
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
{
Int choice=0 switch (choice)
{
Case0;
printf(“Mumbai”);
Case1;
printf(“Pune”);
}
getch();
}
Weightage
Performance indicators
60%
Process related: 30 Marks
1. Debugging ability 20%
40%
Product related: 20 Marks
1. Completion and submission of practical in time 20%
Practical No. 13: Implement C minimum 2 C programs using 'while' loop and 'do—while'
loop statements.
I. Practical Significance
Loops are used in programming to repeat a specific block of code.
Students will be able to write programs using different loop
statements.
II. Industry /Employer Expected Outcome
This practical is expected to develop the following skills as:
Develop ‘C’ programs that address issues with processing of repetitions based on conditions.
VII. Exercise
Write a C program to:
1. Find sum of digits of a given number.
2.Generate multiplication table up to 10 for numbers 1 to 5
VIII. Algorithm
Weightage
Performance indicators
Process related: 30 Marks 60%
Debugging ability 20%
1.
Correctness of Program codes 30%
2.
I. Practical Significance
Student will be able to understand the nesting of different loops
statements. Students will be able to use different nested loop.
Write syntax for while and do ... while loop Write syntax for 'for' loop
VII. Exercise
Write a C program to :
1.Write C Program to print following or similar pattern
****
***
**
*
2.Write C Program to print following or similar pattern
1
12
123
1234
VIII. Algorithm
printf(“/n%”,x*y); getch();
}
4.Write a C program to generate the output as follows:
4
43
432
4321
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
I. Practical Significance
Students will be able to write programs using arrays and store multiple variable
values under one variable name with subscript and understand contiguous storage
location used in memory for storing these variables.
Arrays are used to store multiple values in a single variable, instead of declaring
Separate variable for each value.
To create an array, define the data type (like int) and specify the name of the array
followed by square brackets [].
Syntax: -
Declaration of array:
At Compile Time :
Syntax:
Data type arrayname={values of integer};
Example
int num[5]={1,3,4,10,9};
integer array num stores 5 elemnts
At Run time :
By using for loop array elements get initialized
Example
int n, i,arr[i];
printf("Enter total number of elements(1 to 100): ");
scanf("%d",&n);
for(i=0;i<n;++i) /* Stores number entered by user. */
{
printf("Enter Number %d:
",i+1);
scanf("%d”,&arr[i]);
}
VII. Exercise
1. Write C program to input 5 numbers using array and display sum of it.
2. Write C program to print array in ascending order.
VIII. Algorithm
IX. Flowchart
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
Weightage
Performance indicators
60%
Process related: 30 Marks
Debugging ability 20%
1.
Correctness of Program codes 30%
2.
Quality of output achieved (LLO mapped) 10%
3.
40%
Product related: 20 Marks
Completion and submission of practical in time 20%
1.
Answer to sample questions 20%
2.
Total 50 Marks 100%
I. Practical Significance
Students will be able to write programs using two dimensional arrays and store multiple
variable values under one variable name with subscript and understand contiguous storage
locations used in memory for storing these variables.
VII. Exercise
1. Write C program to calculate addition of two 3X3 matrices.)
2. Write C program to calculate multiplication of two 3X3 matrices.)
VIII. Algorithm
XII. Precautions
1. Handle computer system with care. '
2. Strictly follow the instructions for writing, compiling and executing the program.
3. Start and Shutdown system with proper procedure.
4. Don't forget to include header file related to functions.
5. Array should be declared and used properly.
6. Array size should be given properly.
XIII. Conclusion
.......... ……………………………………………………………………………
…………………………………………………………………………………..
……………………………………………………………………………
XV. References / Suggestions for further Reading Software/Learning Website
1. https://www.w3schools.in/c-tutorial/operators/
2. https://www.w3schools.com/c/c_arrays.php
3. https://www.programiz.com/c-programming/c-arrays#google_vignette
Dated Sign of
Teacher
Marks obtained
Product
Related (35) Total
Process (50)
Related (10)
Practical No 18: Write C program to perform following operations without using standard string
functions.
I. Practical Significance
The C string functions are built-in functions that can be used for various operations and
manipulations on strings. These string functions can be used to perform tasks such as string
copy, concatenation, comparison, length, etc. Students will be able to write programs using
string handling functions.
Declaration of string:
Initialization of string:
int main(){
char name[20];
printf("Enter name:
");
scanf("%s",name);
printf("Your name is
%s.",name); return 0;
}
VII. Exercise
Calculate Length of given string.
Print reverse of given string.
VIII.Algorithm
IX. Flowchart
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
Main()
{
Char str[ ]=”Good
Morning”; If (strstr
(str,”hi”)==0) Printf(“\n
string Found”):
}
Weightage
Performance indicators
Process related: 30 Marks 60%
Debugging ability 20%
1.
I. Practical Significance
An array of structures in C can be defined as the collection of multiple structures
variables where each variable contains information about different entities. The array
of structures in C are used to store information about multiple entities of different data
types. The array of structures is also known as the collection of structures. Students
will be able to write programs using structures.
......
......
};
VII. Exercise
1. Accept and Display 10 employees ’s information using structure.
2. Accept and Display 10 books information using structure.
VIII. Algorithm
IX. Flowchart
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
1.Point out the errors, if any, in the following program struct virus
{
};
main( )
int i ;
2. A record contains the name of cricketer, his age, number of test matches that he has
played and the average runs that he has scored in each test match. Create an array of
structure to hold records of 20 such cricketer and then write a program to read these
records.
[Space for Answer]
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
40%
Product related: 20 Marks
Completion and submission of practical in time 20%
1.
Answer to sample questions 20%
2.
Total 50 Marks 100%
Practical No.21 : Develop C program using in-built mathematical and string functions.
•
I Practical Significance
This practical will be helpful for the students to define and declare user defined functions
and library functions and use different string handling functions, mathematical functions as
well as miscellaneous functions. Students will be able to develop the ability to compare
strings, copy strings, generate random members, sine, cosine and log values.
Exercise
1. Checking palindrome using string function
2. Calculating average using mathematical function
VIII Algorithm
IX Flowchart
XI Required Resources:
XII Precautions
1. Handle computer system with care.
2. Strictly follow the instructions for writing, compiling, and executing the program.
3. Start and shutdown system with proper procedure.
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
Void main( )
{
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
……………………………………………………………………………
Dated Sign of
Marks obtained
Teacher
Product Total
Process 50
Related 35
Related 10
I. Practical Significance
Students will be able to define and declare user define functions and can understand the
scope of variables. Students will use parameters using call by value and call by reference in
C program.
C Function Prototype
A function prototype is also known as a function declaration which specifies the function’s
name, function parameters, and return type.
Syntax
return_type function_name (type1 arg1, type2 arg2, ... typeN argN);
C Function Call
To transfer control to a user-defined function, we need to call it. Functions are called using
their names followed by round brackets. Their arguments are passed inside the brackets.
Syntax
function_name(arg1, arg2, ... argN);
VII. Exercise
1. Find factorial of a given number using function
2. Create a function to find GCD of given number. Call this function in a program.
VIII. Algorithm
IX. Flowchart
a.main()
display()
b.main ()
int i = 45, c ;
c = check(i ) ;
printf (“\n%d", c ) ; check (int ch )
{
Practical No 24: Write C Program to print addresses and values of variables using Pointer.
I. Practical Significance
Students will be able to understand the concept of pointer variables and how to access their
addresses. Students will be able to declare, initialize and access pointers. After the
completion of this practical student will be able to use pointers to get the memory address
of variable.
Syntax:-
data_type * name_of_variable;
Example:-
int *ptr ;
Here ptr variable of data type integer pointer is declared as name of variable ‟ptr‟ is
preceded by * (indirection operator) means that variable ptr is a pointer variable.
Pointers are initialized by address of another variable and for accessing address of a
variable “Address of “operator is used.
This operator will fetch address of variable to which it prefix (Precedes).
ptr=&name_of_variable;
VII. Exercise
1. Write C program to access and display address of variables.
VIII. Algorithm
IX. Flowchart
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
int***r,**q,*p,i=5; p=&i;
Maharashtra State Board of Technical Education (K Scheme)
Programming in C (312303)
q=&p; r=&q;
printf(“%d%d%d”,*p,**q,***r);
int*b=
&a;
int*c=
b;
int d=*b+*c;
Weightage
Performance indicators
Process related: 30 Marks 60%
40%
Product related: 20 Marks
1. Completion and submission of practical in time 20%
Practical No. 25: Implement C programs to perform arithmetic operations using pointer.
I. Practical Significance
Student will be able to understand arithmetic operations that can be performed on
pointers. Students will be able to write a c program to perform arithmetic operations
on pointers.
Concept and need for functions. Concept of library functions like Math and String functions.
Arithmetic Operators are the type of operators in C that are used to perform
mathematical operations in a C program. They can be used in programs to define
expressions and mathematical formulas.
What are C Arithmetic Operators?
The C arithmetic operators are the symbols that are used to perform mathematical
operations on operands. There are a total of 9 arithmetic operators in C to provide the
basic arithmetic operations such as addition, subtraction, multiplication, etc.
Types of Arithmetic Operators in C
The C Arithmetic Operators are of two types based on the number of operands they
work on.
Pointers
A pointer is defined as a derived data type that can store the address of other C variables or a
memory location. We can access and manipulate the data stored in that memory location
using pointers.
As the pointers in C store the memory addresses, their size is independent of the type of
data they are pointing to. This size of pointers in C only depends on the system
architecture.
Syntax of C Pointers
The syntax of pointers is similar to the variable declaration in C, but we use the ( * )
dereferencing operator in the pointer declaration.
datatype *
ptr; where
VII. Exercise
1.Addition using pointer
2.Subtraction using pointer
3.Multiplication using pointer
4. Division using pointer
VIII. Algorithm
XII. Precautions
1. Handle computer system with care. '-
2. Strictly follow the instructions for writing, compiling and executing the program.
3. Start and Shutdown system with proper procedure.
4. You Should take care to define and declare pointers.
XIII. Conclusion
……………………………………………………………………………
……………………………………………………………………………
Weightage
Performance indicators
60%
Process related: 30 Marks
Debugging ability 20%
1.
Correctness of Program codes 30%
2.
Quality of output achieved (LLO mapped) 10%
3.
40%
Product related: 20 Marks
Completion and submission of practical in time 20%
1.
Answer to sample questions 20%
2.
Total 50 Marks 100%