This document discusses structures in C++. It defines a structure as a collection of related data items that can be of different types. Structures allow grouping of data together, like elements in a student record. Individual structure members can be accessed using the dot operator. Arrays of structures and structures containing arrays are also discussed. Examples are provided to demonstrate defining, declaring, initializing, and assigning values to structures and nested structures.
Introduction to control structure in C Programming Language include decision making (if statement, if..else statement, if...else if...else statement, nested if...else statement, switch...case statement), Loop(for loop, while loop, do while loop, nested loop) and using keyword(break, continue and goto)
Detailing about basics of C language and its control structure for learning C Language for beginners. It covers looping statement , control statement etc.
Introduction to control structure in C Programming Language include decision making (if statement, if..else statement, if...else if...else statement, nested if...else statement, switch...case statement), Loop(for loop, while loop, do while loop, nested loop) and using keyword(break, continue and goto)
Detailing about basics of C language and its control structure for learning C Language for beginners. It covers looping statement , control statement etc.
This page contains examples and source code on decision making in C programming (to choose a particular statement among many statements) and loops ( to perform repeated task ). To understand all the examples on this page, you should have knowledge of following topics:
if...else Statement
for Loop
while Loop
break and Continue Statement
switch...case
C lecture 3 control statements slideshareGagan Deep
Control Statement in C, Looping in C, Conditional and Unconditional Statements, For Loop, While Loop, Do-While Loop, C Programming, Examples : Visit us at www.rozyph.com
Operators and expressions in c languagetanmaymodi4
what is operator in c language
uses of operator in c language
syatax of operator in c language
program of operator in c language
what is expressions in c language
use of expressions in c language
syantax of expressions in c language
This page contains examples and source code on decision making in C programming (to choose a particular statement among many statements) and loops ( to perform repeated task ). To understand all the examples on this page, you should have knowledge of following topics:
if...else Statement
for Loop
while Loop
break and Continue Statement
switch...case
C lecture 3 control statements slideshareGagan Deep
Control Statement in C, Looping in C, Conditional and Unconditional Statements, For Loop, While Loop, Do-While Loop, C Programming, Examples : Visit us at www.rozyph.com
Operators and expressions in c languagetanmaymodi4
what is operator in c language
uses of operator in c language
syatax of operator in c language
program of operator in c language
what is expressions in c language
use of expressions in c language
syantax of expressions in c language
Good morning Salma Hayek you have to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you have to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you have to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you want me potter to plant in spring I will be there in the morning Salma Hayek you have a nice weekend with someone legally allowed in spring a contract for misunderstanding and tomorrow I hope it was about the best msg you want me potter you want me potter you want to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you have to do it up but what do you think about the pros of the morning Salma good mornings are you doing well and tomorrow I hope it goes well and I hope you to do it goes well and tomorrow I have to be there at both locations in spring a nice day service and I hope it goes away soon as I can you have to be to get a I hope it goes away soon I hope it goes away soon I hope it goes away soon as I can you have to be to work at a time I can do is
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
USER DEFINED DATATYPES
STRUCTURE
UNION
TYPEDEF
DIFFERENCE BETWEEN STRUCTURE AND UNION
ENUMERATION (ENUM)
QUIZ SET 4
Transmission Control Protocol and User Datagram protocolSamsil Arefin
The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, the entire suite is commonly referred to as TCP/IP.
n computer networking, the User Datagram Protocol (UDP) is one of the core members of the Internet protocol suite. The protocol was designed by David P. Reed in 1980 and formally defined in RFC 768.
A phylogenetic tree or evolutionary tree is a branching diagram or "tree" showing the inferred evolutionary relationships among various biological species or other entities—their phylogeny—based upon similarities and differences in their physical or genetic characteristics.
Bio-informatics is one of the most popular topic today. here we make a presentation in pptx about Evolution Phylogenetic. I think it maybe helpful to others.
Augmented reality (AR) is a live direct or indirect view of a physical, real-world environment whose elements are "augmented" by computer-generated or extracted real-world sensory input such as sound, video, graphics, haptics or GPS data.[1] It is related to a more general concept called computer-mediated reality, in which a view of reality is modified (possibly even diminished rather than augmented) by a computer. Augmented reality enhances one’s current perception of reality, whereas in contrast, virtual reality replaces the real world with a simulated one.
Client Server is networking based project.We made presentation slides to present this topic.It is helpful to everyone.Here we talked about socket programming too.
Program to sort the n names in an alphabetical orderSamsil Arefin
It is a cpp program.Sort names by alphabetical order.
Users give some names as input and they will get sorted name by alphabetical order.I think that it may be helpful to others
I am telling about basic c such as variable,constant,operators,decison making,loops,switch,break and continue,function,call by value ,call by reference and recursion.In this pdf i give some practice problems too.
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
Presented at NUS: Fuzzing and Software Security Summer School 2024
This keynote talks about the democratization of fuzzing at scale, highlighting the collaboration between open source communities, academia, and industry to advance the field of fuzzing. It delves into the history of fuzzing, the development of scalable fuzzing platforms, and the empowerment of community-driven research. The talk will further discuss recent advancements leveraging AI/ML and offer insights into the future evolution of the fuzzing landscape.
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
2. 2
P102 Prog. Fundamentals, Structures / Slide 2
Structures
A Structure is a collection of related data items,
possibly of different types.
A structure type in C++ is called struct.
A struct is heterogeneous in that it can be
composed of data of different types.
In contrast, array is homogeneous since it can
contain only data of the same type.
3. 3
P102 Prog. Fundamentals, Structures / Slide 3
Structures
Structures hold data that belong together.
Examples:
Student record: student id, name, major,
gender, start year, …
Bank account: account number, name,
currency, balance, …
Address book: name, address, telephone
number, …
In database applications, structures are called
records.
4. 4
P102 Prog. Fundamentals, Structures / Slide 4
Structures
Individual components of a struct type are
called members (or fields).
Members can be of different types (simple,
array or struct).
A struct is named as a whole while individual
members are named using field identifiers.
Complex data structures can be formed by
defining arrays of structs.
5. 5
P102 Prog. Fundamentals, Structures / Slide 5
struct basics
Definition of a structure:
struct <struct-type>{
<type> <identifier_list>;
<type> <identifier_list>;
...
} ;
Example:
struct Date {
int day;
int month;
int year;
} ;
The “Date” structure
has 3 members,
day, month & year.
Each identifier
defines a member
of the structure.
6. 6
P102 Prog. Fundamentals, Structures / Slide 6
struct examples
Example:
struct StudentInfo{
int Id;
int age;
char Gender;
double CGA;
};
Example:
struct StudentGrade{
char Name[15];
char Course[9];
int Lab[5];
int Homework[3];
int Exam[2];
};
The “StudentGrade”
structure has 5
members of
different array types.
The “StudentInfo”
structure has 4 members
of different types.
7. 7
P102 Prog. Fundamentals, Structures / Slide 7
struct examples
Example:
struct BankAccount{
char Name[15];
int AcountNo[10];
double balance;
Date Birthday;
};
Example:
struct StudentRecord{
char Name[15];
int Id;
char Dept[5];
char Gender;
};
The “StudentRecord”
structure has 4
members.
The “BankAcount”
structure has simple,
array and structure
types as members.
8. 8
P102 Prog. Fundamentals, Structures / Slide 8
struct basics
Declaration of a variable of struct type:
<struct-type> <identifier_list>;
Example:
StudentRecord Student1, Student2;
Student1 and Student2 are variables of
StudentRecord type.
Student1 Student2
Name
Id Gender
Dept
Name
Id Gender
Dept
9. 9
P102 Prog. Fundamentals, Structures / Slide 9
Chan Tai Man
12345 M
COMP
Ex. 1: struct basics
The members of a struct type variable are
accessed with the dot (.) operator:
<struct-variable>.<member_name>;
Example:
strcpy(Student1.Name, "Chan Tai Man");
Student1.Id = 12345;
strcpy(Student1.Dept, "COMP");
Student1.gender = 'M';
cout << "The student is ";
switch (Student1.gender){
case 'F': cout << "Ms. "; break;
case 'M': cout << "Mr. "; break;
}
Student1
Name
Id Gender
Dept
11. 11
102 Prog. Fundamentals, Structures / Slide 11
Chan Tai Man
12345 M
COMP
Ex. 2: struct-to-struct assignment
The values contained in one struct type
variable can be assigned to another variable
of the same struct type.
Example:
strcpy(Student1.Name,
"Chan Tai Man");
Student1.Id = 12345;
strcpy(Student1.Dept, "COMP");
Student1.gender = 'M';
Student2 = Student1;
Student1
Chan Tai Man
12345 M
COMP
Student2
13. 13
102 Prog. Fundamentals, Structures / Slide 13
Ex. 3-5: Nested structures
We can nest structures inside structures.
Examples:
struct point{
double x, y;
};
point P;
struct line{
point p1, p2;
};
line L;
struct triangle{
point p1, p2, p3;
};
triangle T;
(P.x, P.y)
(L.p1.x, L.p1.y)
(L.p2.x, L.p2.y)
(T.p2.x, T.p2.y)
(T.p1.x, T.p1.y)
(T.p3.x, T.p3.y)
14. 14
102 Prog. Fundamentals, Structures / Slide 14
Ex. 3-5: Nested structures
We can nest structures inside structures.
struct line{
point p1, p2;
};
line L; (L.p1.x, L.p1.y)
(L.p2.x, L.p2.y)
line
p1 p2
x y x y
15. 15
102 Prog. Fundamentals, Structures / Slide 15
Ex. 3-5: Nested structures
Assign values to the variables P, L, and T
using the picture:
point P;
line L;
triangle T;
(4, 11)
(2, 7)
(10, 9)
(6, 5)
(2, 0)
(8, 3)
Ex. 3: Graph a point
Ex. 4: Graph a line
Ex. 5: Graph a triangle
17. 17
102 Prog. Fundamentals, Structures / Slide 17
Ex. 3: Graphing a Point
x
5
4
3
2
1
1514131211100876543210
y
(x1, y1)
*
18. struct point {int x, y;};
void user_input(point&);
void graph_point(char grid[NUMBER_ROWS][NUMBER_COLS], point);
void print_grid(char grid[NUMBER_ROWS][NUMBER_COLS]);
void set_background(char grid[][NUMBER_COLS]);
void user_input(point& P){ // pass by reference
// get user input and check that it is on the grid
do{
cout << "Enter column (x<" << NUMBER_COLS << ") & row (y<"
<< NUMBER_ROWS <<") of the 1st point: ";
cin >> P.x >> P.y;
} while ((P.y<0) || (P.y >= NUMBER_ROWS) ||
(P.x<0) || (P.x >= NUMBER_COLS));
}
// Put a point on the grid
void graph_point(char grid[][NUMBER_COLS], point P){
grid[P.y][P.x] = '*';
}
20. 20
102 Prog. Fundamentals, Structures / Slide 20
Ex. 4: Trajectory Between 2 Points
x
*5
4
3
2
*1
1514131211100876543210
y
• The equation of a line going through two points
(x1, y1) & (x2, y2) can be represented by:
(y-y1)/ (x-x1) = (y2-y1)/(x2-x1)
or y = ((y2-y1)/(x2-x1)) (x-x1) + y1
where (y -y )/(x -x ) is called the slope.
(x1, y1)
(x2, y2)
*
*
*
21. // use struct to graph line between two points
#include <ctype> // for tolower
#include <iostream>
using namespace std;
int const NUMBER_ROWS = 11;
int const NUMBER_COLS = 31;
struct point {int x, y;};
struct line {point p1, p2;};
void user_input (line&);
void graph_line (char grid[NUMBER_ROWS][NUMBER_COLS], line);
void print_grid(char grid[NUMBER_ROWS][NUMBER_COLS]);
void set_background (char grid[][NUMBER_COLS]);
22. // Graph line between two points
int main(){
// set an array for the grid
char grid[NUMBER_ROWS][NUMBER_COLS];
line line1;
int row1=0, col1=0, row2=0, col2=0;
char do_another;
// function call to fill background of grid with ‘-’
set_background(grid);
do{ // do-while loop allows multiple lines
// get user input
user_input(line1);
// put ‘*’ into array to graph the line(s) on the grid
graph_line(grid, line1);
// print the grid from the array to the screen
print_grid(grid);
cout << "Do you want to add another line (y/n)? ";
cin >> do_another;
do_another = tolower(do_another);
} while (do_another == 'y');
return 0;
}
23. 23
102 Prog. Fundamentals, Structures / Slide 23
Ex. 4: More on Graphing Line
//A function to get user input and check that it is on the grid.
void user_input(line& line1){
do{
cout << "Enter column (x<" << NUMBER_COLS
<< ") & row (y<" << NUMBER_ROWS
<< ") coordinates of the 1st point: ";
cin >> line1.p1.x >> line1.p1.y;
} while ((line1.p1.y<0) ||
(line1.p1.y>=NUMBER_ROWS) ||
(line1.p1.x<0) ||
(line1.p1.x >= NUMBER_COLS));
// use another do-while loop for the 2nd
point, col2 and row2
}
24. 24
102 Prog. Fundamentals, Structures / Slide 24
Ex. 4: More on Graphing Line
void graph_line(char grid[][NUMBER_COLS], line line1){
int row, col;
double rise, run, slope;
// one point
if((line1.p1.y==line1.p2.y)&&(line1.p1.x==line2.p2.x))
grid[line1.p1.y][line1.p1.x] = '*';
else if(line1.p2.x==line1.p1.x){ // infinite slope
if (line1.p1.y < line1.p2.y){
for(row=line1.p1.y; row <= line1.p2.y; row++)
grid[row][line1.p1.x] = '*';
}
else{
for(row=line1.p1.y; row >= line1.p2.y; row--)
grid[row][line1.p1.x] = '*';
}
}
25. 25
102 Prog. Fundamentals, Structures / Slide 25
Ex. 4: More on Graphing Line
else{
rise=line1.p2.y-line1.p1.y; run=line1.p2.x-line1.p1.x;
slope = (double)rise / run; // run cannot = 0
if (run >0){
for(col = line1.p1.x; col <= line1.p2.x; col++){
// line1.p1.y is offset for starting point
row=(int)(slope*(col–line1.p1.x)+line1.p1.y);
grid[row][col] = '*';
}
}
else{
for(col=line1.p1.x; col >= line1.p2.x; col--){
row=(int)(slope*(col–line1.p1.x)+line1.p1.y);
grid[row][col] = '*';
}
}
}
}
27. 27
102 Prog. Fundamentals, Structures / Slide 27
Arrays of structures
An ordinary array: One type of data
An array of structs: Multiple types of data in each
array element.
0 1 2 … 98 99
0 1 2 … 98 99
28. 28
102 Prog. Fundamentals, Structures / Slide 28
Arrays of structures
We often use arrays of structures.
Example:
StudentRecord Class[100];
strcpy(Class[98].Name, "Chan Tai Man");
Class[98].Id = 12345;
strcpy(Class[98].Dept, "COMP");
Class[98].gender = 'M';
Class[0] = Class[98];
. . .
0 1 2 … 98 99
Chan Tai Man
12345 M
COMP
29. 29
102 Prog. Fundamentals, Structures / Slide 29
Arrays inside structures
We can use arrays inside structures.
Example:
struct square{
point vertex[4];
};
square Sq;
Assign values to Sq using the given square
(4, 3) (10, 3)
(4, 1) (10, 1)
x y x y x y x y