SlideShare a Scribd company logo
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C for Beginners
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Agenda
• Introduction to C
• Variables in C
• Datatypes in C
• Input / Output in C
• Operators in C
• C Control Statements
• Arrays in C
• Functions in C
• Strings in C
• Structures and Union
• Pointers in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Introduction to C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Introduction to C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
• C was first introduced by Dennis Ritchie.
• C is a procedure-oriented language.
• C is a widely used and popular programming language for developing system application software.
• It can be called as a mid-level programming language.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Introduction to C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Features:
Some of the features of C Programming are:-
• Easy to learn
• Structured Programming language
• Machine Independent or Portable
• Powerful
• Used in low- level as well as high level applications
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Basic block of a C Program
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Preproccesor directives
Global declarations;
void main()
{
local declarations;
statement 1;
statement 2;
:
statement n;
}
User defined functions
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Comments
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
/* This is my First C Program
Author name: */
# include<stdio.h>
#include<conio.h>
void main()
{
printf(“C Programming”); // Single line Comment
getch();
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Tokens
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
C tokens are smallest individual units in a program.
● Identifiers- user defined names/abbreviations
● Keywords - words which are specific to C language
● Constants - values which don't change
● Strings - sequence of characters
● Operators - act on operands and generates output
● Special Symbols - used for preprocessor directives (#)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Variables in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Variables in C
What is a Variable?
• It’s a name given to a memory location where the value is not fixed, it can change with the course of
time. Ex : int num;
Syntax:
datatype variable_name;
Assignment:
variable_name = value
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Scope of a Variable
• Scope generally speaks about the visibility of variables.
- local variable and global variable
Local Global
Variables in C
void main ()
{
int rollno = 10;
}
int y = 50;
void main ()
{
int x = 100;
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Data Types in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Data Types in C
Data Types
Primitive Data type Derived Data type User Defined type
Boolean
Character
Integer
Float
Double
Void
Array
Pointer
References
Structure
Union
Enum
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Typecasting
• C allows for conversions between the basic data types
- Implicit and Explicit
Data Types in C
int num = 5 + 13.75; // num = 18
float a = 5.25;
int b = (int) a; // b = 5
Implicit conversion Explicit conversion
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Input / Output in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Input / Output in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Input and Output functions in C are:-
• printf() and scanf()
• gets() and puts()
• getchar() and putchar()
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Input / Output in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Format Specifiers:-
The format specifiers will inform the scanf() function, what kind of input is being fed through input
device. It also tells printf() function what type of data has to be printed on the output device.
• %d – Integer
• %c – Character
• %s – String
• %f - Float
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Operators in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Operators in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
• C primarily supports 5 types of operators
Arithmetic Relational Bitwise
Logical Assignment
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Operators in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Arithmetic Operators:-
• Used for mathematical operations
• We have unary and binary operators
• Unary – ( ++, --)
• Binary – (+ , - , *, /, %)
Relational Operators:-
• Used to compare the values of two operands
• Some of them are ( < , <= , >=, ==)
• We can also check for equality of operands, whether an operand is greater or smaller than the
other.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Operators in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Logical Operators:
• To combine one or multiple conditions we can use Logical operators.
• Logical operators always give us a Boolean value, i.e. true or false
• Some of them are ( && - AND, || - OR, ! – NOT)
Bitwise Operators:-
• We can perform bit-level operations on the operands.
• Some of them are ( & - bitwise AND, |- bitwise OR)
• It converts them to bit-level first and then performs the operations.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Operators in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Assignment Operator:-
• It is used to assign a value to a given variable.
• The value on the right side of the assignment operator is assigned to operand at left side.
• We also have some short hand assignment operators ( +=, -=, /=).
.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Conditional Statements:-
• Also known as selection statements.
• Based on the conditions specified we can make some decisions.
• Anytime we execute conditional statements we get a Boolean value in return.
• If the condition executed returns a true value, a set of statements are executed else another set of
statements are executed.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
The if statement:-
• Selection and execution of statements based on a given condition is done by the if statement.
Syntax:
if (condition)
{
statement 1;
statement 2;
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
The if-else statement:-
• Depending on the result of the condition, the if - else statement executes one of the two potential
statements.
Syntax:
if (condition)
{
statement 1; // if block
statement 2;
}
else
{
statement 3: // else block
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
The Nested if-else statement:-
• A nested if-else contains one or more if-else statements.
if (condition1)
{
statement 1;
if(condition2)
statement 2;
else
statement 3;
}
else
{
statement 3:
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Loops:-
• Loops are used to re-execute a part of a code a given number of times, depending upon the
condition specified.
Entry controlled:-
• The condition is checked each-time before entering the loop. If the condition is satisfied then only
the loop body gets executed. The loop body does not get executed if the condition is false in the
first iteration.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Entry controlled loops are:-
1) For loop
Syntax:
for(i=0 ;i<n; i++){
//do something
}
2) While Loop
Syntax:
while(condition is True){
//do something
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Switch case:-
● The switch statement works as a multiway branch statement.
● It’s a modified form of if-else.
● It’s a common alternative to the if statement when you want to get multiple results.
● Default condition gets executed when no conditions are met.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
C Control Statements
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Switch case:-
#include<stdio.h>
#include<conio.h>
void main() {
int n= 1;
switch (n)
{
case 1: Statement 1;
break;
case 2: Statement 2;
break;
default: Statement;
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Arrays in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Arrays in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
● An array is a collection of elements where the data types of all the elements are same.
● An array stores all the elements in contiguous memory locations.
● Every element in an array has a specified index.
● Size of an array in C is fixed at the time of definition
We have two types in Arrays:
Single dimensional
Multi-dimensional
1 x 3 Array
2 x 3 Array
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Arrays in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Definition:
An array can be defined in the following manner in C:
Data_type name_of_array>[<size_of_array>]
Note: Size of an array should always be an integer it cannot be a real value.
Example:
int a[10]; //single dimensional array
float b[3][3]; //float - dimensional array
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Arrays in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Array initialization:
1) Static Initialization
int a[10]={0,1,2,3,4,5,6}
char c[5]={‘h’,’e’,’l’,’l’,’o’}
2) Dynamic Initialization
int a[10]; //array is created with garbage value
for (int i=0 ;i<10; i++)
scanf(“%d”,&a[i]);
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Functions in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Functions in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
● Functions are blocks of code which are used to perform specific tasks .
● In C a function needs to be declared before it’s used.
● Functions have a function definition , function body and a return type.
● Functions with return type except void needs to return a value at the end.
● Functions with return type void do not return any value.
● A recursive function can call itself during the course of execution of a program.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Functions in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
A Function example:
int sum (int a, int b)
{
return a+b;
}
void main()
{
printf(“ %d”, sum(5,10));
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Strings in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Strings in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
● Strings are used to store sequence of characters as information.
● string.h header file provides some built-in string manipulation functions.
Strings can be initialized in following ways:-
char a[5] = {‘H’,’o’,’l’,’a’};
char a [ ] = “Hola”;
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Strings in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
String functions are accessible by importing <string.h>.
● strlen() Find length of string
● strcpy() Copy one string to other
● strcat() Join two strings
● strcmp() Compare two strings
● strlwr() Converts string to lowercase
● strupr() Converts string to uppercase
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Structures and Union
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Structures and Union
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
● Structures provides a way for us to create our own data type called “ user-defined data type”
● Assume that we have to store the details of a student, so we can use structure to store it as below:
struct student
{
char name[10];
int rollno;
float cgpa;
} ;
name
rollno
cgpa
student
Structure
allocates space
for each variable
separately
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Structures and Union
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
● Union also provides a way for us to create our own data type called “ user-defined data type”.
● Here each variable shares the memory collectively.
union student
{
char name[10];
int rollno;
float cgpa;
} ;
name
rollno
cgpa
student
Union shares the
memory
allocated for
variables
Memory
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Pointers in C
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Pointers in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
● Pointers are variables which store the address of a variable.
● They have data type just like variables, for example an integer type pointer can hold the address of
an integer variable and an character type pointer can hold the address of char variable.
Example:
int a =20;
int *p=&a; 1001 2063
20 1001
a *p
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Pointers in C
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Example of Pointer:
#include <stdio.h>
void main ()
{
int y = 5;
int *p;
p = &y;
printf("Address of y : %xn", &y );
printf("Content of p: %xn", p );
printf("Content of *p: %dn", *p );
}
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Summary
• We saw an introduction to C, features available in C and tokens available in C.
• Then, we started with variables, how to declare and use them.
• Next, we came across, what are the data types which we can use here in C language.
• Then we went through the input and output functions, how can we process the input and display
results.
• Operators available in C through which we can perform various operations on our data.
• Various controls statements such as if, if..else, loops and switch case.
• Next, we introduced arrays in C, how to declare and use them with examples.
• Next up, we saw what functions are, how to use them in the program and recursion.
• Later we came across Strings, how to declare and built-in functions available in string.h.
• We introduced Structures and Union with an example for each.
• A brief introduction to pointers, how to declare and use them with example.

More Related Content

Similar to C+for+beginners (2).pdf hsudiksbdjdidkdnjd

Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
8759000398
 
Option Data Types in IBM Streams V4.3
Option Data Types in IBM Streams V4.3Option Data Types in IBM Streams V4.3
Option Data Types in IBM Streams V4.3
lisanl
 
JavaScript: Operators and Expressions
JavaScript: Operators and ExpressionsJavaScript: Operators and Expressions
JavaScript: Operators and Expressions
LearnNowOnline
 
JavaMicroBenchmarkpptm
JavaMicroBenchmarkpptmJavaMicroBenchmarkpptm
JavaMicroBenchmarkpptm
Srinivasan Raghavan
 
9781337102087 ppt ch04
9781337102087 ppt ch049781337102087 ppt ch04
9781337102087 ppt ch04
Terry Yoast
 
Cypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationCypress Best Pratices for Test Automation
Cypress Best Pratices for Test Automation
Knoldus Inc.
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
Whats Newi in C# 8.0
Whats Newi in C# 8.0Whats Newi in C# 8.0
Whats Newi in C# 8.0
Manoj Sharma
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 
CP c++ programing project Unit 1 intro.pdf
CP c++ programing project  Unit 1 intro.pdfCP c++ programing project  Unit 1 intro.pdf
CP c++ programing project Unit 1 intro.pdf
ShivamYadav886008
 
9781337102087 ppt ch06
9781337102087 ppt ch069781337102087 ppt ch06
9781337102087 ppt ch06
Terry Yoast
 
Chapter 5 - The Selection Structure
Chapter 5 - The Selection StructureChapter 5 - The Selection Structure
Chapter 5 - The Selection Structure
mshellman
 
Open mp
Open mpOpen mp
Open mp
Gopi Saiteja
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1
Ahmad Bashar Eter
 
Software Development, Data Types, and Expressions
Software Development, Data Types, and ExpressionsSoftware Development, Data Types, and Expressions
Software Development, Data Types, and Expressions
pullaravikumar
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
Thapar Institute
 
Anagha
AnaghaAnagha
Clean architecture
Clean architectureClean architecture
Clean architecture
Travis Frisinger
 
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
Ahmad Gohar
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principles
Xiaoyan Chen
 

Similar to C+for+beginners (2).pdf hsudiksbdjdidkdnjd (20)

Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Option Data Types in IBM Streams V4.3
Option Data Types in IBM Streams V4.3Option Data Types in IBM Streams V4.3
Option Data Types in IBM Streams V4.3
 
JavaScript: Operators and Expressions
JavaScript: Operators and ExpressionsJavaScript: Operators and Expressions
JavaScript: Operators and Expressions
 
JavaMicroBenchmarkpptm
JavaMicroBenchmarkpptmJavaMicroBenchmarkpptm
JavaMicroBenchmarkpptm
 
9781337102087 ppt ch04
9781337102087 ppt ch049781337102087 ppt ch04
9781337102087 ppt ch04
 
Cypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationCypress Best Pratices for Test Automation
Cypress Best Pratices for Test Automation
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
Whats Newi in C# 8.0
Whats Newi in C# 8.0Whats Newi in C# 8.0
Whats Newi in C# 8.0
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
CP c++ programing project Unit 1 intro.pdf
CP c++ programing project  Unit 1 intro.pdfCP c++ programing project  Unit 1 intro.pdf
CP c++ programing project Unit 1 intro.pdf
 
9781337102087 ppt ch06
9781337102087 ppt ch069781337102087 ppt ch06
9781337102087 ppt ch06
 
Chapter 5 - The Selection Structure
Chapter 5 - The Selection StructureChapter 5 - The Selection Structure
Chapter 5 - The Selection Structure
 
Open mp
Open mpOpen mp
Open mp
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1
 
Software Development, Data Types, and Expressions
Software Development, Data Types, and ExpressionsSoftware Development, Data Types, and Expressions
Software Development, Data Types, and Expressions
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
Anagha
AnaghaAnagha
Anagha
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principles
 

Recently uploaded

Interview Methods - Marital and Family Therapy and Counselling - Psychology S...
Interview Methods - Marital and Family Therapy and Counselling - Psychology S...Interview Methods - Marital and Family Therapy and Counselling - Psychology S...
Interview Methods - Marital and Family Therapy and Counselling - Psychology S...
PsychoTech Services
 
Senior Software Profiles Backend Sample - Sheet1.pdf
Senior Software Profiles  Backend Sample - Sheet1.pdfSenior Software Profiles  Backend Sample - Sheet1.pdf
Senior Software Profiles Backend Sample - Sheet1.pdf
Vineet
 
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdfsaps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
newdirectionconsulta
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
22ad0301
 
Salesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - CanariasSalesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - Canarias
davidpietrzykowski1
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
Vineet
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
ywqeos
 
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
Timothy Spann
 
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance PaymentCall Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
prijesh mathew
 
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
Call Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call GirlCall Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call Girl
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
sapna sharmap11
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
Vietnam Cotton & Spinning Association
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
nhutnguyen355078
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
TeukuEriSyahputra
 
PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)
PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)
PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)
Rebecca Bilbro
 
SAP BW4HANA Implementagtion Content Document
SAP BW4HANA Implementagtion Content DocumentSAP BW4HANA Implementagtion Content Document
SAP BW4HANA Implementagtion Content Document
newdirectionconsulta
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
keesa2
 
Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7
Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7
Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7
nitachopra
 
Telemetry Solution for Gaming (AWS Summit'24)
Telemetry Solution for Gaming (AWS Summit'24)Telemetry Solution for Gaming (AWS Summit'24)
Telemetry Solution for Gaming (AWS Summit'24)
GeorgiiSteshenko
 
High Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENT
High Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENTHigh Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENT
High Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENT
ranjeet3341
 
一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理
zsafxbf
 

Recently uploaded (20)

Interview Methods - Marital and Family Therapy and Counselling - Psychology S...
Interview Methods - Marital and Family Therapy and Counselling - Psychology S...Interview Methods - Marital and Family Therapy and Counselling - Psychology S...
Interview Methods - Marital and Family Therapy and Counselling - Psychology S...
 
Senior Software Profiles Backend Sample - Sheet1.pdf
Senior Software Profiles  Backend Sample - Sheet1.pdfSenior Software Profiles  Backend Sample - Sheet1.pdf
Senior Software Profiles Backend Sample - Sheet1.pdf
 
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdfsaps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
 
Salesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - CanariasSalesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - Canarias
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
 
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
 
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance PaymentCall Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
 
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
Call Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call GirlCall Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call Girl
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
 
PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)
PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)
PyData London 2024: Mistakes were made (Dr. Rebecca Bilbro)
 
SAP BW4HANA Implementagtion Content Document
SAP BW4HANA Implementagtion Content DocumentSAP BW4HANA Implementagtion Content Document
SAP BW4HANA Implementagtion Content Document
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
 
Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7
Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7
Call Girls Goa👉9024918724👉Low Rate Escorts in Goa 💃 Available 24/7
 
Telemetry Solution for Gaming (AWS Summit'24)
Telemetry Solution for Gaming (AWS Summit'24)Telemetry Solution for Gaming (AWS Summit'24)
Telemetry Solution for Gaming (AWS Summit'24)
 
High Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENT
High Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENTHigh Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENT
High Profile Call Girls Navi Mumbai ✅ 9833363713 FULL CASH PAYMENT
 
一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理
 

C+for+beginners (2).pdf hsudiksbdjdidkdnjd

  • 1. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C for Beginners
  • 2. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Agenda • Introduction to C • Variables in C • Datatypes in C • Input / Output in C • Operators in C • C Control Statements • Arrays in C • Functions in C • Strings in C • Structures and Union • Pointers in C
  • 3. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Introduction to C
  • 4. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Introduction to C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM • C was first introduced by Dennis Ritchie. • C is a procedure-oriented language. • C is a widely used and popular programming language for developing system application software. • It can be called as a mid-level programming language.
  • 5. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Introduction to C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Features: Some of the features of C Programming are:- • Easy to learn • Structured Programming language • Machine Independent or Portable • Powerful • Used in low- level as well as high level applications
  • 6. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Basic block of a C Program DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Preproccesor directives Global declarations; void main() { local declarations; statement 1; statement 2; : statement n; } User defined functions
  • 7. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Comments DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM /* This is my First C Program Author name: */ # include<stdio.h> #include<conio.h> void main() { printf(“C Programming”); // Single line Comment getch(); }
  • 8. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Tokens DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM C tokens are smallest individual units in a program. ● Identifiers- user defined names/abbreviations ● Keywords - words which are specific to C language ● Constants - values which don't change ● Strings - sequence of characters ● Operators - act on operands and generates output ● Special Symbols - used for preprocessor directives (#)
  • 9. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Variables in C
  • 10. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Variables in C What is a Variable? • It’s a name given to a memory location where the value is not fixed, it can change with the course of time. Ex : int num; Syntax: datatype variable_name; Assignment: variable_name = value
  • 11. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Scope of a Variable • Scope generally speaks about the visibility of variables. - local variable and global variable Local Global Variables in C void main () { int rollno = 10; } int y = 50; void main () { int x = 100; }
  • 12. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Data Types in C
  • 13. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Data Types in C Data Types Primitive Data type Derived Data type User Defined type Boolean Character Integer Float Double Void Array Pointer References Structure Union Enum
  • 14. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Typecasting • C allows for conversions between the basic data types - Implicit and Explicit Data Types in C int num = 5 + 13.75; // num = 18 float a = 5.25; int b = (int) a; // b = 5 Implicit conversion Explicit conversion
  • 15. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Input / Output in C
  • 16. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Input / Output in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Input and Output functions in C are:- • printf() and scanf() • gets() and puts() • getchar() and putchar()
  • 17. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Input / Output in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Format Specifiers:- The format specifiers will inform the scanf() function, what kind of input is being fed through input device. It also tells printf() function what type of data has to be printed on the output device. • %d – Integer • %c – Character • %s – String • %f - Float
  • 18. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Operators in C
  • 19. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Operators in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM • C primarily supports 5 types of operators Arithmetic Relational Bitwise Logical Assignment
  • 20. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Operators in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Arithmetic Operators:- • Used for mathematical operations • We have unary and binary operators • Unary – ( ++, --) • Binary – (+ , - , *, /, %) Relational Operators:- • Used to compare the values of two operands • Some of them are ( < , <= , >=, ==) • We can also check for equality of operands, whether an operand is greater or smaller than the other.
  • 21. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Operators in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Logical Operators: • To combine one or multiple conditions we can use Logical operators. • Logical operators always give us a Boolean value, i.e. true or false • Some of them are ( && - AND, || - OR, ! – NOT) Bitwise Operators:- • We can perform bit-level operations on the operands. • Some of them are ( & - bitwise AND, |- bitwise OR) • It converts them to bit-level first and then performs the operations.
  • 22. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Operators in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Assignment Operator:- • It is used to assign a value to a given variable. • The value on the right side of the assignment operator is assigned to operand at left side. • We also have some short hand assignment operators ( +=, -=, /=). .
  • 23. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements
  • 24. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Conditional Statements:- • Also known as selection statements. • Based on the conditions specified we can make some decisions. • Anytime we execute conditional statements we get a Boolean value in return. • If the condition executed returns a true value, a set of statements are executed else another set of statements are executed.
  • 25. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM The if statement:- • Selection and execution of statements based on a given condition is done by the if statement. Syntax: if (condition) { statement 1; statement 2; }
  • 26. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM The if-else statement:- • Depending on the result of the condition, the if - else statement executes one of the two potential statements. Syntax: if (condition) { statement 1; // if block statement 2; } else { statement 3: // else block }
  • 27. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM The Nested if-else statement:- • A nested if-else contains one or more if-else statements. if (condition1) { statement 1; if(condition2) statement 2; else statement 3; } else { statement 3: }
  • 28. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Loops:- • Loops are used to re-execute a part of a code a given number of times, depending upon the condition specified. Entry controlled:- • The condition is checked each-time before entering the loop. If the condition is satisfied then only the loop body gets executed. The loop body does not get executed if the condition is false in the first iteration.
  • 29. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Entry controlled loops are:- 1) For loop Syntax: for(i=0 ;i<n; i++){ //do something } 2) While Loop Syntax: while(condition is True){ //do something }
  • 30. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Switch case:- ● The switch statement works as a multiway branch statement. ● It’s a modified form of if-else. ● It’s a common alternative to the if statement when you want to get multiple results. ● Default condition gets executed when no conditions are met.
  • 31. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited C Control Statements DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Switch case:- #include<stdio.h> #include<conio.h> void main() { int n= 1; switch (n) { case 1: Statement 1; break; case 2: Statement 2; break; default: Statement; }
  • 32. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Arrays in C
  • 33. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Arrays in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM ● An array is a collection of elements where the data types of all the elements are same. ● An array stores all the elements in contiguous memory locations. ● Every element in an array has a specified index. ● Size of an array in C is fixed at the time of definition We have two types in Arrays: Single dimensional Multi-dimensional 1 x 3 Array 2 x 3 Array
  • 34. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Arrays in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Definition: An array can be defined in the following manner in C: Data_type name_of_array>[<size_of_array>] Note: Size of an array should always be an integer it cannot be a real value. Example: int a[10]; //single dimensional array float b[3][3]; //float - dimensional array
  • 35. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Arrays in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Array initialization: 1) Static Initialization int a[10]={0,1,2,3,4,5,6} char c[5]={‘h’,’e’,’l’,’l’,’o’} 2) Dynamic Initialization int a[10]; //array is created with garbage value for (int i=0 ;i<10; i++) scanf(“%d”,&a[i]);
  • 36. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Functions in C
  • 37. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Functions in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM ● Functions are blocks of code which are used to perform specific tasks . ● In C a function needs to be declared before it’s used. ● Functions have a function definition , function body and a return type. ● Functions with return type except void needs to return a value at the end. ● Functions with return type void do not return any value. ● A recursive function can call itself during the course of execution of a program.
  • 38. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Functions in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM A Function example: int sum (int a, int b) { return a+b; } void main() { printf(“ %d”, sum(5,10)); }
  • 39. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Strings in C
  • 40. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Strings in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM ● Strings are used to store sequence of characters as information. ● string.h header file provides some built-in string manipulation functions. Strings can be initialized in following ways:- char a[5] = {‘H’,’o’,’l’,’a’}; char a [ ] = “Hola”;
  • 41. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Strings in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM String functions are accessible by importing <string.h>. ● strlen() Find length of string ● strcpy() Copy one string to other ● strcat() Join two strings ● strcmp() Compare two strings ● strlwr() Converts string to lowercase ● strupr() Converts string to uppercase
  • 42. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Structures and Union
  • 43. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Structures and Union DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM ● Structures provides a way for us to create our own data type called “ user-defined data type” ● Assume that we have to store the details of a student, so we can use structure to store it as below: struct student { char name[10]; int rollno; float cgpa; } ; name rollno cgpa student Structure allocates space for each variable separately
  • 44. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Structures and Union DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM ● Union also provides a way for us to create our own data type called “ user-defined data type”. ● Here each variable shares the memory collectively. union student { char name[10]; int rollno; float cgpa; } ; name rollno cgpa student Union shares the memory allocated for variables Memory
  • 45. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Pointers in C
  • 46. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Pointers in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM ● Pointers are variables which store the address of a variable. ● They have data type just like variables, for example an integer type pointer can hold the address of an integer variable and an character type pointer can hold the address of char variable. Example: int a =20; int *p=&a; 1001 2063 20 1001 a *p
  • 47. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited Pointers in C DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Example of Pointer: #include <stdio.h> void main () { int y = 5; int *p; p = &y; printf("Address of y : %xn", &y ); printf("Content of p: %xn", p ); printf("Content of *p: %dn", *p ); }
  • 48. Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited DO NOT WRITE ANYTHING HERE. LEAVE THIS SPACE FOR WEBCAM Summary • We saw an introduction to C, features available in C and tokens available in C. • Then, we started with variables, how to declare and use them. • Next, we came across, what are the data types which we can use here in C language. • Then we went through the input and output functions, how can we process the input and display results. • Operators available in C through which we can perform various operations on our data. • Various controls statements such as if, if..else, loops and switch case. • Next, we introduced arrays in C, how to declare and use them with examples. • Next up, we saw what functions are, how to use them in the program and recursion. • Later we came across Strings, how to declare and built-in functions available in string.h. • We introduced Structures and Union with an example for each. • A brief introduction to pointers, how to declare and use them with example.