SlideShare a Scribd company logo
Recall
• Difference between while and do while?
• Difference between == and =
• Difference between break and continue?
• What is the difference between i++ and
++i
• What if i didn’t give break in switch?
• What is the difference between logical
operators and relational operators
Introduction to C
functions - Arrays – structures - pointers
Week 2- day 2
Functions
Functions
• A function is a group of statements that
together perform a task.
return_type function_name ( parameter list )
{
body of the function
}
Eg: main()
{
Printf(“hello world”);
Functions
int equation(int num1, int num2)
{
int result;
result = num1*num1+2*num1*num2+num2*num2;
return result;
}
Return Type
Function name
Arguments
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ;
Printf(“%d”,c);
}
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
//Function body / function Definition
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
Should I use the same variable names?
Are they same of what I used in main() ?
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
Absolutely not !!!
Variable a in equation() is different from
varaible a in main(). There is no
connection between those two
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
What is this return???
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
Return will simply send value out of
function to whomsoever it was called
#include<stdio.h>
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
Can i write the whole function body after
main function??
#include<stdio.h>
int equation(int a, int b) ;
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
Yes you can. But only additional thing you
need to do is
#include<stdio.h>
int equation(int a, int b) ;
Int main ()
{
int a,b,c;
Printf(“Enter the number”);
Scanf(“%d %d”,&a ,&b);
c = equation (a,b) ; // Calling the function
Printf(“%d”,c);
}
int equation(int a, int b)
{
int c;
c= a*a+2*a*b+b*b;
return c;
}
You must declare it at the beginning
Arrays
Arrays
• Is a collection of data of same type with
common name
• Eg: int a[6]
A[5]
A[4]
A[3]
A[2]
A[1]
A[0]
Memory
Each Cell will be size of int
Example
Main()
{
int a[10];
For(i=0;i<10;i++)
Scanf(“%d”,&a[i]);
For(i=0;i<10;i++)
printf(“%d”, a[i]);
}`
Strings in C
• There is no string data type in C
• But we can do the same with character
array in C
– Eg: char a[8] =“baabtra”//enables us to store
string with 6 characters
/0
A
R
T
B
A
A
B
A[7]
A[6]
a[5]
a[4]
a[3]
a[2]
a[1]
a[0]
main()
{
Char a[7]=“baabtra”; //Correct
Char *p=“baabtra”; //Correct
a=“baabtra”; //Incorrect
Scanf(“%s”,&a); //Correct
Scanf(“%s”, a); //Correct;But
why?? will discuss soon
Printf(“%s”,a);
}
Structures
• A structure is a collection of variables
under a single name
• These variables can be of different types,
and each has a name which is used to
select it from the structure.
struct struct_name
{
//Variable declarations;
}
Why structures?
• A structure is a convenient way of
grouping several pieces of related
information together.
• Eg: suppose there are several variables
called name,age,gender related to a
student . So we can bring all of them
under one name student using structures
• Eg: struct student
{
Char name[25];
Int age;
struct student
{
Char gender;
Int age;
}
main()
{
Struct student john,Mary;
John.age=15;
John.gender=“m”;
Mary.age=16;
Mary.gender=“f”;
}
age
gender
Student
Pointers
• Pointers simply points to locations in
memory
• Each variables will be having a address in
the memory. So pointer is just another
variable which simply stores the address
of it
Main()
{
int a,b, *p,*q;
1002
1001
25
99
1004
1003
1002
1001
q
p
b
a
Main()
{
int a,*p;
a=15;
P=&a;
Printf(“%d,%d ”,&a,p); // Will print 1001,1001
Printf (“%d, %d”,a,*p); // Will print 15,15
}
1001
15
1002
1001
p
a
Character array as pointer
Character array is a pointer to the first location of
a group of locations
Eg : char a[10];
Here a stores memory address of a[0]
main()
{
char a[10]="baabtra";
printf("%d %d",&a[0],a); // will print the
same address
A
R
T
B
A
A
B
A[6]
a[5]
a[4]
a[3]
a[2]
a[1]
a[0]
1006
1005
1004
1003
1002
1001
1000
Questions?
“A good question deserve a good
grade…”
Self Check !!
Self - Check
#include<stdio.h>
Main()
{
Int a,b,c;
Printf(“Sum = %d”,sum(a,b));
}
Sum(int a,int b)
{
Return a+b;
}
Self - Check
#include<stdio.h>
Int sum(int a,int b)
Main()
{
Int a,b,c;
Printf(“Sum = %d”,sum(a,b));
}
Int sum(int a,int b)
{
Return a+b;
}
Self- Check
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}
A.2, 1,
15
B.1, 2, 5
C.3, 2,
15
D.2, 3,
Self- Check
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}
A.2, 1, 1
5
B.1, 2, 5
C.3, 2, 1
5
D.2, 3, 2
Self- Check
• A pointer to a block of memory is
effectively same as an array
A.True
B.False
Self- Check
• A pointer to a block of memory is
effectively same as an array
A.True
B.False
Self- Check
Which of the following are themselves
a collection of different data types?
a) string
b) structures
c) char
d) All of the mentioned
Self- Check
Which of the following are themselves
a collection of different data types?
a) string
b) structures
c) char
d) All of the mentioned
Self- Check
Which of the following cannot
be a structure member?
a) Another structure
b) Function
c) Array
d) None of the mentioned
Self- Check
Which of the following cannot
be a structure member?
a) Another structure
b) Function
c) Array
d) None of the mentioned
Self- Check
#include <stdio.h>
void main()
{
char *s= "hello";
char *p = s;
printf("%ct%c", p[0], s[1]);
}
a) Run time err
b) h h
c) h e
d) h l
Self- Check
#include <stdio.h>
void main()
{
char *s= "hello";
char *p = s;
printf("%ct%c", p[0], s[1]);
}
a) Run time err
b) h h
c) h e
d) h l
Self- Check
#include<stdio.h>
struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course c[] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"} };
printf("%d ", c[1].courseno);
printf("%sn", (*(c+2)).coursename);
return 0;
}
A.103 DotNet
B.102 Java
C.103 PHP
D.104 DotNet
Self- Check
#include<stdio.h>
struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course c[] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"} };
printf("%d ", c[1].courseno);
printf("%sn", (*(c+2)).coursename);
return 0;
}
A.104 DotNet
B.102 Java
C.103 PHP
D.103 DotNet
Self- Check
#include <stdio.h>
void foo( int[] );
int main()
{
int ary[4] = {1, 2, 3, 4};
foo(ary);
printf("%d ", ary[0]);
}
void foo(int p[4])
{
int i = 10;
p = &i;
printf("%d ", p[0]);
}
a) 10 10
b) Compile time
c) 10 1
d) Undefined be
Self- Check
#include <stdio.h>
void foo( int[] );
int main()
{
int ary[4] = {1, 2, 3, 4};
foo(ary);
printf("%d ", ary[0]);
}
void foo(int p[4])
{
Int i=10;
p = &i;
printf("%d ", p[0]);
}
a) 10 10
b) Compile time
c) 10 1
d) Undefined be
End of Day 2

More Related Content

PPTX
Function basics
PDF
Stl algorithm-Basic types
PDF
C program
DOCX
Data Structure Project File
PPT
Doublylinklist
PDF
Programming Fundamentals Arrays and Strings
Function basics
Stl algorithm-Basic types
C program
Data Structure Project File
Doublylinklist
Programming Fundamentals Arrays and Strings

What's hot (20)

PDF
Data struture lab
PDF
PDF
6. function
PPT
Arrays
DOCX
Data structure new lab manual
PPSX
C programming pointer
PPTX
Function recap
PDF
VTU Data Structures Lab Manual
PDF
Data structure lab manual
PPSX
C programming array & shorting
DOC
Ds lab manual by s.k.rath
PDF
C Prog - Array
DOC
C tech questions
DOCX
Data Structure in C (Lab Programs)
DOCX
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
PDF
C++ Question on References and Function Overloading
PDF
Data structures lab manual
PDF
C++ ARRAY WITH EXAMPLES
DOC
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
PDF
Recursion concepts by Divya
Data struture lab
6. function
Arrays
Data structure new lab manual
C programming pointer
Function recap
VTU Data Structures Lab Manual
Data structure lab manual
C programming array & shorting
Ds lab manual by s.k.rath
C Prog - Array
C tech questions
Data Structure in C (Lab Programs)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
C++ Question on References and Function Overloading
Data structures lab manual
C++ ARRAY WITH EXAMPLES
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
Recursion concepts by Divya
Ad

Similar to Introduction to c part 2 (20)

PDF
The best every notes on c language is here check it out
PPTX
USER DEFINE FUNCTION AND STRUCTURE AND UNION
PPTX
Introduction to functions in C programming language
PPTX
Introduction to c
PPTX
Functions in c
PPT
An imperative study of c
PPTX
programming in C and Datastructures deepdive
PPTX
C language
PDF
programming in C & Data structures an easy approach
PDF
[ITP - Lecture 12] Functions in C/C++
PPT
Fucntions & Pointers in C
PPT
C Tutorials
PPTX
1. DSA - Introduction.pptx
PPTX
data structure and c programing concepts
PDF
Principals of Programming in CModule -5.pdfModule-3.pdf
PPTX
Advance topics of C language
PPT
C tutorial
PPT
C tutorial
The best every notes on c language is here check it out
USER DEFINE FUNCTION AND STRUCTURE AND UNION
Introduction to functions in C programming language
Introduction to c
Functions in c
An imperative study of c
programming in C and Datastructures deepdive
C language
programming in C & Data structures an easy approach
[ITP - Lecture 12] Functions in C/C++
Fucntions & Pointers in C
C Tutorials
1. DSA - Introduction.pptx
data structure and c programing concepts
Principals of Programming in CModule -5.pdfModule-3.pdf
Advance topics of C language
C tutorial
C tutorial
Ad

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
PDF
Acquiring new skills what you should know
PDF
Baabtra.com programming at school
PDF
99LMS for Enterprises - LMS that you will love
PPTX
Chapter 6 database normalisation
PPTX
Chapter 5 transactions and dcl statements
PPTX
Chapter 4 functions, views, indexing
PPTX
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
PPTX
Chapter 1 introduction to sql server
PPTX
Chapter 1 introduction to sql server
Agile methodology and scrum development
Acquiring new skills what you should know
Baabtra.com programming at school
99LMS for Enterprises - LMS that you will love
Chapter 6 database normalisation
Chapter 5 transactions and dcl statements
Chapter 4 functions, views, indexing
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 1 introduction to sql server
Chapter 1 introduction to sql server

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PPTX
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Understanding_Digital_Forensics_Presentation.pptx
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm
Building Integrated photovoltaic BIPV_UPV.pdf
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
Cloud computing and distributed systems.

Introduction to c part 2

  • 1. Recall • Difference between while and do while? • Difference between == and = • Difference between break and continue? • What is the difference between i++ and ++i • What if i didn’t give break in switch? • What is the difference between logical operators and relational operators
  • 2. Introduction to C functions - Arrays – structures - pointers Week 2- day 2
  • 4. Functions • A function is a group of statements that together perform a task. return_type function_name ( parameter list ) { body of the function } Eg: main() { Printf(“hello world”);
  • 5. Functions int equation(int num1, int num2) { int result; result = num1*num1+2*num1*num2+num2*num2; return result; } Return Type Function name Arguments
  • 6. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; Printf(“%d”,c); }
  • 7. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } //Function body / function Definition
  • 8. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } Should I use the same variable names? Are they same of what I used in main() ?
  • 9. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } Absolutely not !!! Variable a in equation() is different from varaible a in main(). There is no connection between those two
  • 10. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } What is this return???
  • 11. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } Return will simply send value out of function to whomsoever it was called
  • 12. #include<stdio.h> int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } Can i write the whole function body after main function??
  • 13. #include<stdio.h> int equation(int a, int b) ; Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } Yes you can. But only additional thing you need to do is
  • 14. #include<stdio.h> int equation(int a, int b) ; Int main () { int a,b,c; Printf(“Enter the number”); Scanf(“%d %d”,&a ,&b); c = equation (a,b) ; // Calling the function Printf(“%d”,c); } int equation(int a, int b) { int c; c= a*a+2*a*b+b*b; return c; } You must declare it at the beginning
  • 16. Arrays • Is a collection of data of same type with common name • Eg: int a[6] A[5] A[4] A[3] A[2] A[1] A[0] Memory Each Cell will be size of int
  • 18. Strings in C • There is no string data type in C • But we can do the same with character array in C – Eg: char a[8] =“baabtra”//enables us to store string with 6 characters /0 A R T B A A B A[7] A[6] a[5] a[4] a[3] a[2] a[1] a[0]
  • 19. main() { Char a[7]=“baabtra”; //Correct Char *p=“baabtra”; //Correct a=“baabtra”; //Incorrect Scanf(“%s”,&a); //Correct Scanf(“%s”, a); //Correct;But why?? will discuss soon Printf(“%s”,a); }
  • 20. Structures • A structure is a collection of variables under a single name • These variables can be of different types, and each has a name which is used to select it from the structure. struct struct_name { //Variable declarations; }
  • 21. Why structures? • A structure is a convenient way of grouping several pieces of related information together. • Eg: suppose there are several variables called name,age,gender related to a student . So we can bring all of them under one name student using structures • Eg: struct student { Char name[25]; Int age;
  • 22. struct student { Char gender; Int age; } main() { Struct student john,Mary; John.age=15; John.gender=“m”; Mary.age=16; Mary.gender=“f”; } age gender Student
  • 23. Pointers • Pointers simply points to locations in memory • Each variables will be having a address in the memory. So pointer is just another variable which simply stores the address of it Main() { int a,b, *p,*q; 1002 1001 25 99 1004 1003 1002 1001 q p b a
  • 24. Main() { int a,*p; a=15; P=&a; Printf(“%d,%d ”,&a,p); // Will print 1001,1001 Printf (“%d, %d”,a,*p); // Will print 15,15 } 1001 15 1002 1001 p a
  • 25. Character array as pointer Character array is a pointer to the first location of a group of locations Eg : char a[10]; Here a stores memory address of a[0] main() { char a[10]="baabtra"; printf("%d %d",&a[0],a); // will print the same address A R T B A A B A[6] a[5] a[4] a[3] a[2] a[1] a[0] 1006 1005 1004 1003 1002 1001 1000
  • 26. Questions? “A good question deserve a good grade…”
  • 28. Self - Check #include<stdio.h> Main() { Int a,b,c; Printf(“Sum = %d”,sum(a,b)); } Sum(int a,int b) { Return a+b; }
  • 29. Self - Check #include<stdio.h> Int sum(int a,int b) Main() { Int a,b,c; Printf(“Sum = %d”,sum(a,b)); } Int sum(int a,int b) { Return a+b; }
  • 30. Self- Check int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } A.2, 1, 15 B.1, 2, 5 C.3, 2, 15 D.2, 3,
  • 31. Self- Check int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } A.2, 1, 1 5 B.1, 2, 5 C.3, 2, 1 5 D.2, 3, 2
  • 32. Self- Check • A pointer to a block of memory is effectively same as an array A.True B.False
  • 33. Self- Check • A pointer to a block of memory is effectively same as an array A.True B.False
  • 34. Self- Check Which of the following are themselves a collection of different data types? a) string b) structures c) char d) All of the mentioned
  • 35. Self- Check Which of the following are themselves a collection of different data types? a) string b) structures c) char d) All of the mentioned
  • 36. Self- Check Which of the following cannot be a structure member? a) Another structure b) Function c) Array d) None of the mentioned
  • 37. Self- Check Which of the following cannot be a structure member? a) Another structure b) Function c) Array d) None of the mentioned
  • 38. Self- Check #include <stdio.h> void main() { char *s= "hello"; char *p = s; printf("%ct%c", p[0], s[1]); } a) Run time err b) h h c) h e d) h l
  • 39. Self- Check #include <stdio.h> void main() { char *s= "hello"; char *p = s; printf("%ct%c", p[0], s[1]); } a) Run time err b) h h c) h e d) h l
  • 40. Self- Check #include<stdio.h> struct course { int courseno; char coursename[25]; }; int main() { struct course c[] = { {102, "Java"}, {103, "PHP"}, {104, "DotNet"} }; printf("%d ", c[1].courseno); printf("%sn", (*(c+2)).coursename); return 0; } A.103 DotNet B.102 Java C.103 PHP D.104 DotNet
  • 41. Self- Check #include<stdio.h> struct course { int courseno; char coursename[25]; }; int main() { struct course c[] = { {102, "Java"}, {103, "PHP"}, {104, "DotNet"} }; printf("%d ", c[1].courseno); printf("%sn", (*(c+2)).coursename); return 0; } A.104 DotNet B.102 Java C.103 PHP D.103 DotNet
  • 42. Self- Check #include <stdio.h> void foo( int[] ); int main() { int ary[4] = {1, 2, 3, 4}; foo(ary); printf("%d ", ary[0]); } void foo(int p[4]) { int i = 10; p = &i; printf("%d ", p[0]); } a) 10 10 b) Compile time c) 10 1 d) Undefined be
  • 43. Self- Check #include <stdio.h> void foo( int[] ); int main() { int ary[4] = {1, 2, 3, 4}; foo(ary); printf("%d ", ary[0]); } void foo(int p[4]) { Int i=10; p = &i; printf("%d ", p[0]); } a) 10 10 b) Compile time c) 10 1 d) Undefined be