Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 LEVEL-4

2 NOTE S

3 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(); }

4 NOTE S

5

6 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); }

7 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; }

8 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(); }

9 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; }

10 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); }

11 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); }

12 NOTE S

13 EXTR A

14

15

16

17 #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; }

18 EXTR A

19

20

21 #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(); }

22 EXTR A

23 #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”); }

24 EXTR A

25

26 NOTE S

27

28 #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(); }

29 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);

30 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(); }

31 EXTR A

32 NOTE S

33 #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(); }


Download ppt "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."

Similar presentations


Ads by Google