LEVEL-4. NOTE S System Define function #include void main() { int num; float r; clrscr(); printf(“Enter any no\n”); scanf(“%d”,&num); r=sqrt(num); printf(“root.

Slides:



Advertisements
Similar presentations
Recursion Prog #include <stdio.h> #include<conio.h> main()
Advertisements

UNIONS IN C.  Union Data Type Union Data Type  Defining of Union Defining of Union  Memory Space Allocation Memory Space Allocation  Example of Union.
Pointer to Structure. Structure variable can be access using pointers int a=10,*p; Here p  is an integer type pointer variable, p can hold the address.
Sort the given string, without using string handling functions.
Functions a group of declarations and statements that is assigned a name effectively, a named statement block usually has a value a sub-program when we.
Understanding Loops Using C Language Week 15 Mr.Omer Salih.
1 Passing Array Array’s element can be passed individually to a function; copying value exist during passing process. An entire array can be passed to.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Functions in C Computer Programming(1)- 1090CS Manesh T
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
 Introduction Introduction  Types of Function Types of Function  Library function Library function  User defined function User defined function 
MAHENDRAN CHAPTER 6. Session Objectives Explain Type of Functions Discuss category of Functions Declaration & Prototypes Explain User Defined Functions.
Reading the data from the input devices and displaying the results on the screen are the two main tasks of any program. To perform these tasks user friendly.
Data structure and c K.S. Prabhu Letterer All Deaf Educational Technology.
LECTURE 11 TYPES OF USER DEFINE FUNCTIONS ITC-414.
PASSING VALUE TO A FUNCTION # CALL BY VALUECALL BY VALUE # CALL BY REFERENCECALL BY REFERENCE STORAGE CLASS # AUTOAUTO # EXTERNALEXTERNAL # STATICSTATIC.
Topics to be covered  Introduction to array Introduction to array  Types of array Types of array  One dimensional array One dimensional array  Declaration.
Enumerated Data Type. An enumeration consists of a set of named integer constants. An enumeration type declaration gives the name of the (optional) enumeration.
Chapter 6: Control Structures Computer Programming Skills Second Term Department of Computer Science Foundation Year Program Umm Alqura.
FUNCTIONS AND STRUCTURED PROGRAMMING CHAPTER 10. Introduction A c program is composed of at least one function definition, that is the main() function.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
UniMAP SemII-09/10EKT120: Computer Programming1 Week 6 – Functions (2)
Lecture 4: C/C++ Control Structures Computer Programming Control Structures Lecture No. 4.
Functions Exercise 5. Functions a group of declarations and statements that is assigned a name  effectively, a named statement block  usually has a.
UNIT - 4 FUNCTIONS AND POINTERS. FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");
Passing Structure to function.  structure to function structure to function  Passing structure to function in C Passing structure to function in C 
FUNCTIONS A function is a set of instructions that can perform a specific task accordingly. A function is a program that performs a specific task according.
Struct 1. Definition: Using struct to define a storage containing different types. For example it can contain int, char, float and array at the same time.
Definition of function Types of Function Built-in User Defined Catagories of Function No argument No return value Argument but No return value No argument.
Decision Making It is used to change the order of the program based on condition. Categories: – Sequential structure – Selection structure – Iteration.
How to design and code functions Chapter 4 (ctd).
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Strings program. C Program to Check if a given String is Palindrome #include void main() { char string[25], reverse_string[25] = {'\0'}; int i, length.
Strings program. C Program to Check if a given String is Palindrome #include void main() { char string[25], reverse_string[25] = {'\0'}; int i, length.
Functions. Why use functions? They can break your problem down into smaller sub-tasks (modularity).  easier to solve complex problems They make a program.
For Loop Lecture No 8. Definition In computer science a for loop is a programming language statement which allows code to be repeatedly executed. A for.
Types of Operator Arithmetic operator Relational operator Logical operator Assignment operator Increment or decrement operator(unary) Bitwise operator.
BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI (MCS, MCSE, CCNA)2 Chapter No: 04 “Loops”
POINTERS IN C Pointer Basics, Pointer Arithmetic, Pointer to arrays and Pointer in functions.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
1 Today: Functions. 2 Some General Tips on Programming Write your code modularly Compile + test functionality in the process.
CSC COMPUTER EDUCATION, M.K.B.NAGAR CHAPTER 3. CSC COMPUTER EDUCATION, M.K.B.NAGAR Session Objectives Explain If, If..else statements Understand Looping.
Week 4 – Functions Coding Functions. Purpose of Coding Functions A function is written to perform a well-defined task; rather than having all logic in.
UNIT - 5 FUNCTIONS AND POINTERS. FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
The Repetition control structure using while loop.
Programming in C.
Control Structures Introduction
WHILE, DO-WHILE AND FOR LOOPS
Chapter 4 Function and Structure.
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Decisions Chapter 4.
LESSON 3 IO, Variables and Operators
UNIT 5 POINTERS AND FILES
Functions Department of Computer Science-BGU יום רביעי 12 ספטמבר 2018.
CHAPTER 7 RECURSIVE FUNCTION
Functions Dr. Ashish Sasankar. In programming, a function is a segment that groups code to perform a specific task. A C program has at least one function.
Tejalal Choudhary “C Programming from Scratch” Pointers
Visit for more Learning Resources
מבוא כללי למדעי המחשב תרגול 2
Chapter 5 POINTERs.
S. Kiran, PGT (CS) KV, Malleswaram
Structure ការណែនាំអំពី Structure
Compile Time polymorphism.
Loops in C.
Recursion Prog #include <stdio.h> #include<conio.h> main()
Control Statements_2.
In C Programming Language
The Pointers of Structures
Course Outcomes of Programming In C (PIC) (17212, C203):
Presentation transcript:

LEVEL-4

NOTE S

System Define function #include void main() { int num; float r; clrscr(); printf(“Enter any no\n”); scanf(“%d”,&num); r=sqrt(num); printf(“root of %d is %f \n”, num,r); getch(); }

NOTE S

User Define Function Parameter and no return value #include void add(int, int); void main() { int a,b; clrscr(); printf(“Enter two number\n”); scanf(“%d%d”,&a,&b); printf(“Value of A =%d\n”,a); printf(“Value of B =%d\n”,b); add(a,b); getch(); }no return void add(int x, int y) { with Parameter int z; z=x+y; printf(“Sum of two no = %d\n”,z); }

User Define Function Parameter and return value #include int add(int, int); void main() { int a,b,c; clrscr(); printf(“Enter two number\n”); scanf(“%d%d”,&a,&b); printf(“Value of A =%d\n”,a); printf(“Value of B =%d\n”,b); c=add(a,b); printf(“Sum of two no = %d\n”,c); getch(); } with return int add(int x, int y) {with parameter int z; z=x+y; return z; }

User Define Function No Parameter and no return value #include void disp(); void main() { clrscr(); disp(); getch(); }no return void disp() {no parameter int a,b,c; printf(“Enter two number\n”); scanf(“%d%d”,&a,&b); printf(“Value of A =%d\n”,a); printf(“Value of B =%d\n”,b); c=a+b; printf(“Sum of two no = %d\n”,c); getch(); }

User Define Function No Parameter and return value #include int fact(); void main() { clrscr(); printf("Factorial %d",fact()); getch(); }with return int fact() {no parameter int n,f=1; printf(" Enter any number\n"); scanf("%d",&n); while(n>=1) { f=n*f; n--; } return f; }

User Define Function Call by value method #include void disp (int, int); void main() { int a,b; clrscr(); printf(“Enter the Value of a & b\n”); scanf(“%d%d”,&a,&b); printf(“Value of a before function %d\n”,a); printf(“Value of b before function %d\n”,b); disp(a,b); printf(“value of a after function %d\n”,a); printf(“Value of b after function %d\n”,b); getch(); } void disp(int a, int b) { a=a+10; b=b+10; printf(“Value of a inside function %d\n”,a); printf(“value of b inside function %d\n”,b); }

User Define Function Call by reference method #include void disp (int &, int&); void main() { int a,b; clrscr(); printf(“Enter the Value of a & b\n”); scanf(“%d%d”,&a,&b); printf(“Value of a before function %d\n”,a); printf(“Value of b before function %d\n”,b); disp(a,b); printf(“value of a after function %d\n”,a); printf(“Value of b after function %d\n”,b); getch(); } void disp(int &a, int &b) { a=a+10; b=b+10; printf(“Value of a inside function %d\n”,a); printf(“value of b inside function %d\n”,b); }

NOTE S

EXTR A

#include int table(int,int); void main() { int n,y=1,t; clrscr(); printf("Enter any no\n"); scanf("%d",&n); table(n,y); getch(); } int table(int n, int y) {int t; if(y==11) { return 0; } else {t=n*y; printf("%d*%d=%d\n",n,y,t); table(n,y+1); } return t; }

EXTR A

#include void main() { int a=5,*p; p=&a; clrscr(); printf(“Value of a = %d\n”,a); printf(“Address of a = %u\n”,p); printf(“Value of *p = %d\n”,*p); printf(“Address of p = %u\n”,&p); getch(); }

EXTR A

#include void greater(int*, int*); void main() { int a,b; clrscr(); printf(“Enter the value of a & b\n”); scanf(“%d%d”,&a,&b); greater(&a,&b); getch(); } void greater(int *a, int *b) { if(*a>*b) { printf(“a is greater then b”); } else { printf(“b is greater then a”); }

EXTR A

NOTE S

#include struct student { char name[20]; int marks; float per; }; void main() { struct student stu; clrscr(); printf(“Enter Student Name\n”); gets(stu.name); printf(“Enter Student Marks\n”); scanf(“%d”,&stu.marks); printf(“Enter Percentage\n”); scanf(“%f”,&stu.per); printf(“NAME:”); puts(stu.name); printf(“MARKS:%d\n”,stu.marks); printf(“PERCENTAGE :%f\n”,stu.per); getch(); }

Structure within structure #include struct address { char street[10]; char city[10]; char state[10]; }; struct employee { char name[20]; char des[10]; struct address add; int salary; }; void main() { struct employee emp; clrscr(); printf("Enter Employee details\n"); printf("Enter Name\n"); gets(emp.name);

printf("Enter Designation\n"); gets(emp.des); printf("Enter Address\n"); printf("Enter street \n"); gets(emp.add.street); printf("Enter City\n"); gets(emp.add.city); printf("Enter State\n"); gets(emp.add.state); printf("Enter Slalry\n"); scanf("%d",&emp.salary); printf("EMPLOYEE DETAILS\n"); printf("NAME:"); puts(emp.name); printf("DESIGNATION:"); puts(emp.des); printf("ADDRESS:\n"); printf("STREET:"); puts(emp.add.street); printf("CITY:"); puts(emp.add.city); printf("STATE:"); puts(emp.add.state); printf("SALARY :%d\n",emp.salary) ; getch(); }

EXTR A

NOTE S

#include union marks {int phy; int che; int mat; int total; float per; }s1; void main() { clrscr(); printf("Enter Marks details\n"); printf("Enter physics marks\n"); scanf("%d",&s1.phy); printf("Enter chemistry marks\n"); scanf("%d",&s1.che); printf("Enter Math Marks\n"); scanf("%d",&s1.mat); s1.total=s1.phy+s1.che+s1.mat; printf("Total Marks = %d\n",s1.total); s1.per=s1.total*1/3; printf("Percentage = %f\n",s1.per); getch(); }