0% found this document useful (0 votes)
22 views

CS3251 - HW - Unit 4

Uploaded by

jeyahr83
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)
22 views

CS3251 - HW - Unit 4

Uploaded by

jeyahr83
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/ 30

All 2nd Semester Subjects

Professional English - II - HS3252 Engineering Graphics - GE3251


Statistics and Numerical Methods - Physics for Electronics Engineering -
MA3251 PH3254
Physics for Electrical Engineering - Physics for Civil Engineering - PH3201
PH3202
Materials Science - PH3251 Basic Electrical and Electronics
Engineering - BE3251
Physics for Information Science - Basic Civil and Mechanical Engineering -
PH3256 BE3255
Basic Electrical and Instrumentation Electric Circuit Analysis (Circuit
Engineering - BE3254 Theory) - EE3251
Programming in C - CS3251 Circuit Analysis - EC3251
Data Structures Design - AD3251
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
www.Poriyaan.in
Union
Union can be defined as a user-defined data type which is a collection of different
variables of different data types in the same memory location. The union can also be defined as
many members, but only one member can contain a value at a particular point in time.
Union is a user-defined data type, but unlike structures, they share the same memory
location.
Syntax
union union name
{
member definition;
member definition;
...
member definition;
} [one or more union variables];
Example

union Data
{
int i;
float f;
char str[20];
} data;

Now, a variable of Data type can store an integer, a floating-point number, or a string of
characters. It means a single variable, i.e., same memory location, can be used to store multiple
types of data. You can use any built-in or user defined data types inside a union based on your
requirement.
Accessing Union Members
To access any member of a union, we use the member access operator (.). The member access
operator is coded as a period between the union variable name and the union member that we
wish to access

#include <stdio.h>
#include <string.h>

union Data {
int i;
float f;
char str[20];
};

int main( ) {

union Data data;

www.Poriyaan.in
data.i = 10;
data.f = 220.5;
strcpy( data.str, "C Programming");

printf( "data.i : %d\n", data.i);


printf( "data.f : %f\n", data.f);
printf( "data.str : %s\n", data.str);

return 0;
}

Output :
data.i : 10
data.f : 220.500000
data.str : C Programming

Accessing members of union using pointers


We can access the members of the union through pointers by using the (->) arrow operator.

#include <stdio.h>
union abc
{
int a;
char b;
};
int main()
{
union abc *ptr; // pointer variable declaration
union abc var;
var.a= 90;
ptr = &var;
printf("The value of a is : %d", ptr->a);
return 0;
}

Output : 90

www.Poriyaan.in
www.Poriyaan.in
Programming in C

Unit I (a): Introduction to Programming


Introduction to Computer Software | Classification of Computer Software | Programming Languages |
Generation of Programming Languages
Unit I (b): Introduction to C
Introduction, Background, Characteristics, Uses of C Programming | Structure of a C Program | Writing the First
C Program | Files Used in a C Program | Compiling and Executing C Programs | Using Comments | C Tokens |
Character Set in C | Keywords | Identifiers | Basic Data Types in C | Variables | Constants | Input/Output |
Statements in C | Operators in C | Type Conversion and Typecasting
Unit I (c): Decision Control and Looping Statements
Introduction to Decision Control Statements | Conditional Branching Statements | Iterative Statements | Nested
Loops | The Break and Continue Statements | goto Statement
Unit I (d): Preprocessor Directives
Introduction of Preprocessor Directives | Types of Preprocessor Directives | #define | #include | #undef | #line |
Pragma Directives | Conditional Directives | Defined Operator | #Error Directive | Predefined Macro Names
Unit II (a): Arrays
Introduction to Arrays in C Programming | Declaration of Array in C | Accessing the Elements of an Array in C |
Storing Values in Arrays | Operations on Arrays | Passing Arrays to Functions | Two-Dimensional Arrays |
Operations on Two-Dimensional Arrays | Passing Two-Dimensional Arrays to Functions | Multidimensional
Arrays | Sparse Matrices (Array Representation) | Applications of Arrays
Unit II (b): Strings
Introduction to Strings in C | Suppressing Input | Strings Taxonomy | Operations on Strings | Miscellaneous
String and Character Functions | Arrays of Strings
Unit III (a): Functions
Introduction to Functions | Using Functions | Function Declaration/Function prototype | Function Definition |
Function Call | Return Statement | Passing Parameters to Functions | Scope of Variables | Storage Classes |
Recursive Functions | Types of Recursion | Tower of Hanoi (recursion) | Recursion Versus Iteration
Unit III (b): Pointers
Understanding the Computer's Memory | Introduction to Pointers | Declaring Pointer Variables | Pointer
Expressions and Pointer Arithmetic | Null Pointers | Generic Pointers | Passing Arguments to Function Using
Pointers | Pointers and Arrays | Passing an Array to Functions | Difference Between Array Name and Pointer |
Pointers and Strings | Arrays of Pointers | Pointers and 2D Arrays | Pointers and 3D Arrays | Function Pointers |
Array of Function Pointers | Pointers to Pointers | Memory Allocation in C Programs | Memory Usage | Dynamic
Memory Allocation | Drawbacks of Pointers
Unit IV: Structures and Union
Structure | Nested Structures | Arrays of Structures | Structure and Functions | Self-referential Structures |
Unions | Arrays of Union Variables | Unions Inside Structures | Structures Inside Unions | Enumerated Data Type
| Memory Allocation and Deallocation for a Linked List | Singly Linked Lists
Unit V: File Processing
Introduction to Files | Using Files in C | Read Data From Files | Writing Data From Files | Detecting the End-of-
File | Error Handling During File Operations | Accepting Command Line Arguments | Function for Selecting a
Record Randomly | Remove()| Renaming the File | Creating a Temporary File
All 2nd Semester Subjects
Professional English - II - HS3252 Engineering Graphics - GE3251
Statistics and Numerical Methods - Physics for Electronics Engineering -
MA3251 PH3254
Physics for Electrical Engineering - Physics for Civil Engineering - PH3201
PH3202
Materials Science - PH3251 Basic Electrical and Electronics
Engineering - BE3251
Physics for Information Science - Basic Civil and Mechanical Engineering -
PH3256 BE3255
Basic Electrical and Instrumentation Electric Circuit Analysis (Circuit
Engineering - BE3254 Theory) - EE3251
Programming in C - CS3251 Circuit Analysis - EC3251
Data Structures Design - AD3251
Civil
CSE
Home Mech
e
EEE
ECE

2nd Semester 3rd Semester


1st Semester
Professional English II Discrete Mathematics
Professional English I
Statistics and Numerical
Methods Digital Principles and
Matrices and Calculus
Computer Organization
Engineering Graphics
Engineering Physics
Foundation of Data
Physics for Information
Science Science
Engineering Chemistry

Physics
Basic for Engineering
Electrical and Data Structure
Problem Solving and Science Engineering
Electronics
Python Programming Object Oriented
Programming in C
Programming

4th Semester 5th Semester 6th Semester


Theory of Computation Computer Networks Object Oriented Software
Engineering
Artificial Intelligence Compiler Design
and Machine Learning Embedded Systems IoT
Cryptography and
Database Management Cyber Security Open Elective I
System
Professional Elective III
Algorithms Distributed Computing
Professional Elective IV

Introduction to Operating Professional Elective I Professional Elective V


Systems
Professional Elective II Professional Elective VI
Environmental Sciences
and sustainability Mandatory Course I Mandatory Course II

7th Semester 8th Semester


Human Values and Ethics Project Work/Internship

Elective-Management

Professional Elective II

Professional Elective III

Professional Elective IV

You might also like