C and C++ Summer Internship Report
C and C++ Summer Internship Report
Submitted By
Submitted To:-
Department of EE
Saharsa College of Engineering
Saharsa
Index of report
1. Acknowledgement
2. Abstract
3. Certificate
4. Training Details (with topics)
Module 1:
• What is C Language, History of C, First C Program
• Printf, scanf, variables, datatypes, keywords, operators
• Control statement (if, switch, conditional operator, goto, loop)
• Functions
• Array
• Pointers
• Structure, Union
• File Handling
Module 2:
• C++ Introduction
• C vs C++
• cout, cin, endl
• class and object
• Constructor
• Destructor
5. Conclusion
ACKNOWLEDGEMENT
-MANISH SAMRAT
(19103132905)
ABSTRACT
C programming is considered as the base for other programming languages, that is why
it is known as mother language.
Histroy of C Language
C programming language was developed in 1972 by Dennis Ritchie at Bell
Laboratories of AT&T (American Telephone & Telegraph), located in the U.S.A.
First C Program
To write the first c program, open the C console and write the following code:
1. #include <stdio.h>
2. int main(){
3. printf("Hello C Language");
4. return 0;
5. }
Variables in C
A variable is a name of the memory location. It is used to store data. Its value can be
changed, and it can be reused many times.
It is a way to represent memory location through symbol so that it can be easily identified.
type variable_list;
Data Types in C
A data type specifies the type of data that a variables can store such as integer, floating,
character,etc.
Keywords in C
A keyword is reserved word. You cannot use it as a variable name, constant name, etc. There
are only 32 reserved words(keywords) in the C language.
Operators
An operator is a symbol that tells the compiler to perform specific mathematical or logical
functions. C language is rich in built-in operators and provides the following types of
operators −
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
Control Statement
In C, the control flows from one instruction to the next instruction until now in all programs.
This control flow from one command to the next is called sequential control flow.
Nonetheless, in most C programs the programmer may want to skip instructions or repeat a
set of instructions repeatedly when writing logic. This can be referred to as sequential control
flow. The declarations in C let programmers make such decisions which are called decision-
making or control declarations
4. Goto Statement
5. Loop Statements
Functions
A function declaration tells the compiler about a function's name, return type, and
parameters. A function definition provides the actual body of the function.
Array
An array is a variable that can store multiple values. For example, if you want to store 100
integers, you can create an array for it.
int data[100];
Pointer
A pointer is a variable whose value is the address of another variable, i.e., direct address of the
memory location. Like any variable or constant, you must declare a pointer before using it to store
any variable address.
int* p;
Structure
A structure is a user defined data type in C/C++. A structure creates a data type that can be
used to group items of possibly different types into a single type.
Before you can create structure variables, you need to define its data type. To define a struct,
Syntax of struct
struct structureName
dataType member1;
dataType member2;
...
};
File Handling
File handling in C refers to the task of storing data in the form of input or output produced by
running C programs in data files, namely, a text file or a binary file for future reference and
analysis.
The C programming offers various operations associated with file handling. They are:
C++ is a general purpose, case-sensitive, free-form programming language that supports object-
oriented, procedural and generic programming.
C++ is a middle-level language, as it encapsulates both high and low level language features.
C vs C++
If bytes flow from main memory to device like printer, display screen, or a network connection,
etc, this is called as output operation.
If bytes flow from device like printer, display screen, or a network connection, etc to main
memory, this is called as input operation.
Since C++ is an object-oriented language, program is designed using objects and classes in
C++.
C++ Object
In C++, Object is a real world entity, for example, chair, car, pen, mobile, laptop etc.
In other words, object is an entity that has state and behaviour. Here, state means data and
behaviour means functionality.
Object is an instance of a class. All the members of the class can be accessed through object.
Let's see an example to create object of student class using s1 as the reference variable.
C++ Class
In C++, object is a group of similar objects. It is a template from which objects are created. It can
have fields, methods, constructors etc.
Let's see an example of C++ class that has three fields only.
1. class Student
2. {
3. public:
7. }
C++ Constructor
In C++, constructor is a special method which is invoked automatically at the time of object
creation. It is used to initialize the data members of new object generally. The constructor in C++
has the same name as class or structure.
o Default constructor
o Parameterized constructor
C++ Destructor
A destructor works opposite to constructor; it destructs the objects of classes. It can be defined only
once in a class. Like constructors, it is invoked automatically.
A destructor is defined like constructor. It must have same name as class. But it is prefixed with a
tilde sign (~).
Note: C++ destructor cannot have parameters. Moreover, modifiers can't be applied on destructors.
Conclusion
It is naive for an Extension professional to feel that if
information is delivered during a learning activity, the
educational mission has been accomplished. The broader
mandate that learning generate change in behaviour,
practice, or belief requires a much more sophisticated science
and art. In today's information-rich culture, Extension's
store of information no longer makes the organization
unique. Rather, Extension's organizational strength and
uniqueness lie in the experience and capability of its
professionals to motivate individuals and groups to action.