SlideShare a Scribd company logo
Lecture
ON
Applications of Strings & Pointers
V.Radhesyam
Assistant professor
Department of IT:VRSEC
Radhesyam.V
Array of Strings
1. #include <stdio.h>
2. int main()
3. {
4. char charr[7][10] = {"sun","mon","tue","wed","thu","fri","sat"};
5. int i;
6. for(i=0;i<7;i++)
7. printf("%sn",charr[i]);
8. return 0;
9. }
2
Output:
sun
mon
tue
wed
thu
fri
sat
Radhesyam.V
Array of Strings
1. #include <stdio.h>
2. Void main()
3. {
4. char charr[7][10];
5. int i;
6. printf("enter string");
7. for(i=0;i<7;i++)
8. scanf("%s",charr[i]);
9. printf("string is ");
10. for(i=0;i<7;i++)
11. printf("%sn",charr[i]);
12. }
3
Maximum no of strings
Maximum string length
Radhesyam.V
Pointer arithmetic
4
1. void main()
2. {
3. int first, second, *p, *q, sum,sub,mul,di;
4. printf("Enter two integers n");
5. scanf("%d%d", &first, &second);
6. p = &first;
7. q = &second;
8. sum = *p + *q;
9. sub = *p - *q;
10.mul = (*p) * (*q);
11.di = (*p) /(*q);
12.printf("Sum of the numbers = %dn", sum);
13.printf("Sub of the numbers = %dn", sub);
14.printf("mul of the numbers = %dn", mul);
15.printf("div of the numbers = %dn", di);
16.}
Radhesyam.V
Double Pointer
5
Radhesyam.V
Double pointer Program
6
1. Void main()
2. {
3. int var = 120;
4. int *varptr = &var;
5. int **doubleptr = &varptr;
6. printf("Value of var = %dn", var );
7. printf("Value of var pointer = %dn", *varptr );
8. printf("Value of double pointer = %dn", **doubleptr);
9. printf("Address of var = %pn", &var );
10. printf("Address of var pointer = %pn", &varptr );
11. printf("Value in var pointer = %pn", varptr );
12. printf("Address of double pointer = %pn", *doubleptr);
13. printf("Value in double pointer = %pn", doubleptr);
14. }
Output:
Value of var = 120
Value of var pointer = 120
Value of double pointer = 120
Address of var = 0x7ffe25192bfc
Address of var pointer = 0x7ffe25192c00
Value in var pointer = 0x7ffe25192bfc
Address of double pointer = 0x7ffe25192bfc
Value in double pointer = 0x7ffe25192c00
Radhesyam.V
Scanf vs gets
7
Scanf() Gets()
scanf() function can read different
data types.
get() function will only get character
string data.
scanf() function takes the format
string and list of addresses of
variables. e.g. scanf(“%d”,
&number);
get() function takes the name of the
variable to store the received value.
e.g. gets(name);
Read multiple values One string
Scanf () reads input until it
encounters whitespace, newline or
End Of File (EOF)
gets () reads input until it encounters
newline or End Of File (EOF)
Radhesyam.V
Fibonacci Series Using Recursion
1. int fib(int n)
2. {
3. if (n <= 1)
4. return n;
5. return fib(n-1) + fib(n-2);
6. }
7. int main ()
8. {
9. int n = 9;
10. printf("%d", fib(n));
11. getchar();
12. return 0;
13. }
8
Radhesyam.V
Ceil()
#include <stdio.h>
#include <math.h>
int main()
{
double num = 8.33;
int result;
result = ceil(num);
printf("Ceiling integer of %.2f = %d", num, result);
return 0;
}
9
Output:
Ceiling integer of 8.33 = 9
Radhesyam.V
Floor()
#include <stdio.h>
#include <math.h>
int main()
{ double num = -8.33;
int result;
result = floor(num);
printf("Floor integer of %.2f = %d", num, result);
return 0;
}
10
Output:
Floor integer of -8.33 = -9
Ad

More Related Content

What's hot (20)

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Acid properties
Acid propertiesAcid properties
Acid properties
NomitaKumawat
 
Dbms4
Dbms4Dbms4
Dbms4
Suleman Mohd
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Function C programming
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Character stream classes introd .51
Character stream classes introd  .51Character stream classes introd  .51
Character stream classes introd .51
myrajendra
 
Arrays
ArraysArrays
Arrays
SARITHA REDDY
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
tanmaymodi4
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
abhishek kumar
 
Characteristics Schedule based on Recover-ability & Serial-ability
Characteristics Schedule based on Recover-ability & Serial-abilityCharacteristics Schedule based on Recover-ability & Serial-ability
Characteristics Schedule based on Recover-ability & Serial-ability
Meghaj Mallick
 
Data model and entity relationship
Data model and entity relationshipData model and entity relationship
Data model and entity relationship
Knowledge Center Computer
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
Way2itech
 
Chapter8 pl sql
Chapter8 pl sqlChapter8 pl sql
Chapter8 pl sql
Jafar Nesargi
 
Searching, Sorting and Hashing Techniques
Searching, Sorting and Hashing TechniquesSearching, Sorting and Hashing Techniques
Searching, Sorting and Hashing Techniques
Selvaraj Seerangan
 
Ppt of operations on one way link list
Ppt of operations on one way  link listPpt of operations on one way  link list
Ppt of operations on one way link list
Sukhdeep Kaur
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programming
Chitrank Dixit
 
Linked list
Linked listLinked list
Linked list
Md. Afif Al Mamun
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL Commands
ShubhamBauddh
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Character stream classes introd .51
Character stream classes introd  .51Character stream classes introd  .51
Character stream classes introd .51
myrajendra
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
tanmaymodi4
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
abhishek kumar
 
Characteristics Schedule based on Recover-ability & Serial-ability
Characteristics Schedule based on Recover-ability & Serial-abilityCharacteristics Schedule based on Recover-ability & Serial-ability
Characteristics Schedule based on Recover-ability & Serial-ability
Meghaj Mallick
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
Way2itech
 
Searching, Sorting and Hashing Techniques
Searching, Sorting and Hashing TechniquesSearching, Sorting and Hashing Techniques
Searching, Sorting and Hashing Techniques
Selvaraj Seerangan
 
Ppt of operations on one way link list
Ppt of operations on one way  link listPpt of operations on one way  link list
Ppt of operations on one way link list
Sukhdeep Kaur
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programming
Chitrank Dixit
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL Commands
ShubhamBauddh
 

Similar to Array strings (20)

string , pointer
string , pointerstring , pointer
string , pointer
Arafat Bin Reza
 
Arrays
ArraysArrays
Arrays
AnaraAlam
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
Arrays
ArraysArrays
Arrays
mohamed sikander
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
Shariful Haque Robin
 
Lexical Analysis and Parsing
Lexical Analysis and ParsingLexical Analysis and Parsing
Lexical Analysis and Parsing
Suman Mia
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
Chhom Karath
 
Array Cont
Array ContArray Cont
Array Cont
Ashutosh Srivasatava
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
C file
C fileC file
C file
simarsimmygrewal
 
Write a program to check a given number is prime or not
Write a program to check a given number is prime or notWrite a program to check a given number is prime or not
Write a program to check a given number is prime or not
aluavi
 
Twitter Author Prediction from Tweets using Bayesian Network
Twitter Author Prediction from Tweets using Bayesian NetworkTwitter Author Prediction from Tweets using Bayesian Network
Twitter Author Prediction from Tweets using Bayesian Network
Hendy Irawan
 
Unit3 C
Unit3 C Unit3 C
Unit3 C
arnold 7490
 
Chapter 6 arrays part-1
Chapter 6   arrays part-1Chapter 6   arrays part-1
Chapter 6 arrays part-1
Synapseindiappsdevelopment
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
C program
C programC program
C program
Komal Singh
 
Algoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - PointersAlgoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - Pointers
martijnkuipersandebo
 
C_Arrays.pptx
C_Arrays.pptxC_Arrays.pptx
C_Arrays.pptx
Debasis Dwibedy
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
Abdullah Al Naser
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
Shariful Haque Robin
 
Lexical Analysis and Parsing
Lexical Analysis and ParsingLexical Analysis and Parsing
Lexical Analysis and Parsing
Suman Mia
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
Write a program to check a given number is prime or not
Write a program to check a given number is prime or notWrite a program to check a given number is prime or not
Write a program to check a given number is prime or not
aluavi
 
Twitter Author Prediction from Tweets using Bayesian Network
Twitter Author Prediction from Tweets using Bayesian NetworkTwitter Author Prediction from Tweets using Bayesian Network
Twitter Author Prediction from Tweets using Bayesian Network
Hendy Irawan
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
Algoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - PointersAlgoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - Pointers
martijnkuipersandebo
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
Abdullah Al Naser
 
Ad

More from Radhe Syam (6)

DS.ppt
DS.pptDS.ppt
DS.ppt
Radhe Syam
 
week4_python.docx
week4_python.docxweek4_python.docx
week4_python.docx
Radhe Syam
 
Pradunma daa
Pradunma daaPradunma daa
Pradunma daa
Radhe Syam
 
Searching&amp;sorting
Searching&amp;sortingSearching&amp;sorting
Searching&amp;sorting
Radhe Syam
 
Structures
StructuresStructures
Structures
Radhe Syam
 
Algorithms and tools for point cloud generation
Algorithms and tools for point cloud generationAlgorithms and tools for point cloud generation
Algorithms and tools for point cloud generation
Radhe Syam
 
week4_python.docx
week4_python.docxweek4_python.docx
week4_python.docx
Radhe Syam
 
Searching&amp;sorting
Searching&amp;sortingSearching&amp;sorting
Searching&amp;sorting
Radhe Syam
 
Algorithms and tools for point cloud generation
Algorithms and tools for point cloud generationAlgorithms and tools for point cloud generation
Algorithms and tools for point cloud generation
Radhe Syam
 
Ad

Recently uploaded (20)

Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
Autodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User InterfaceAutodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User Interface
Atif Razi
 
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Journal of Soft Computing in Civil Engineering
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
Autodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User InterfaceAutodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User Interface
Atif Razi
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 

Array strings

  • 1. Lecture ON Applications of Strings & Pointers V.Radhesyam Assistant professor Department of IT:VRSEC
  • 2. Radhesyam.V Array of Strings 1. #include <stdio.h> 2. int main() 3. { 4. char charr[7][10] = {"sun","mon","tue","wed","thu","fri","sat"}; 5. int i; 6. for(i=0;i<7;i++) 7. printf("%sn",charr[i]); 8. return 0; 9. } 2 Output: sun mon tue wed thu fri sat
  • 3. Radhesyam.V Array of Strings 1. #include <stdio.h> 2. Void main() 3. { 4. char charr[7][10]; 5. int i; 6. printf("enter string"); 7. for(i=0;i<7;i++) 8. scanf("%s",charr[i]); 9. printf("string is "); 10. for(i=0;i<7;i++) 11. printf("%sn",charr[i]); 12. } 3 Maximum no of strings Maximum string length
  • 4. Radhesyam.V Pointer arithmetic 4 1. void main() 2. { 3. int first, second, *p, *q, sum,sub,mul,di; 4. printf("Enter two integers n"); 5. scanf("%d%d", &first, &second); 6. p = &first; 7. q = &second; 8. sum = *p + *q; 9. sub = *p - *q; 10.mul = (*p) * (*q); 11.di = (*p) /(*q); 12.printf("Sum of the numbers = %dn", sum); 13.printf("Sub of the numbers = %dn", sub); 14.printf("mul of the numbers = %dn", mul); 15.printf("div of the numbers = %dn", di); 16.}
  • 6. Radhesyam.V Double pointer Program 6 1. Void main() 2. { 3. int var = 120; 4. int *varptr = &var; 5. int **doubleptr = &varptr; 6. printf("Value of var = %dn", var ); 7. printf("Value of var pointer = %dn", *varptr ); 8. printf("Value of double pointer = %dn", **doubleptr); 9. printf("Address of var = %pn", &var ); 10. printf("Address of var pointer = %pn", &varptr ); 11. printf("Value in var pointer = %pn", varptr ); 12. printf("Address of double pointer = %pn", *doubleptr); 13. printf("Value in double pointer = %pn", doubleptr); 14. } Output: Value of var = 120 Value of var pointer = 120 Value of double pointer = 120 Address of var = 0x7ffe25192bfc Address of var pointer = 0x7ffe25192c00 Value in var pointer = 0x7ffe25192bfc Address of double pointer = 0x7ffe25192bfc Value in double pointer = 0x7ffe25192c00
  • 7. Radhesyam.V Scanf vs gets 7 Scanf() Gets() scanf() function can read different data types. get() function will only get character string data. scanf() function takes the format string and list of addresses of variables. e.g. scanf(“%d”, &number); get() function takes the name of the variable to store the received value. e.g. gets(name); Read multiple values One string Scanf () reads input until it encounters whitespace, newline or End Of File (EOF) gets () reads input until it encounters newline or End Of File (EOF)
  • 8. Radhesyam.V Fibonacci Series Using Recursion 1. int fib(int n) 2. { 3. if (n <= 1) 4. return n; 5. return fib(n-1) + fib(n-2); 6. } 7. int main () 8. { 9. int n = 9; 10. printf("%d", fib(n)); 11. getchar(); 12. return 0; 13. } 8
  • 9. Radhesyam.V Ceil() #include <stdio.h> #include <math.h> int main() { double num = 8.33; int result; result = ceil(num); printf("Ceiling integer of %.2f = %d", num, result); return 0; } 9 Output: Ceiling integer of 8.33 = 9
  • 10. Radhesyam.V Floor() #include <stdio.h> #include <math.h> int main() { double num = -8.33; int result; result = floor(num); printf("Floor integer of %.2f = %d", num, result); return 0; } 10 Output: Floor integer of -8.33 = -9
  翻译: