TRIBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING PURWANCHAL CAMPUS, - TopicsExpress



          

TRIBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING PURWANCHAL CAMPUS, DHARAN Department of Electronics & Computer Engineering C- Programming Lab Sheet 1st Year /1st Part Lab Sheet #4 Objectives:- 1. To familiarized with different parts of function such as function prototype and function definition. 2. Passing arguments by value and return statement to return the value from called to caller. 3. Concept of local, global and static variable. 4. Recursive function Objectives #1 1.1 #include #include void italy(); /*function prototype*/ void brazil(); main() { printf(“\n”I am in the main function\n); italy(); printf(“I am finally back in main function\n”); getch(); } void italy() { printf(“I am in italy function\n”); brazil(); } void brazil() { printf(“I am in italy function\n”); } Assignment 1.1:Using F8 to execute the program and see how the control is transferred from calling function to called function and return back to main function. Note down the output. Objectives #2 2.1 Write a program to add two number using user defined type function with no return type and with argument. #include #include void sum(int x,int y); /*function prototype*/ main() { int a,b; printf(“enter the number a and b”); scanf(“%d%d”,&a,&b); sum(a,b); getch(); } void sum(int x, int y) { int c; c=x+y; printf(“%d”,c); } Note the output and comments about the program. Objectives #2.1 Write a program to check a number is prime number or not using function : #include int isPrime(int); int main() { int num,prime; printf(Enter a positive number: ); scanf(%d,&num); prime = isPrime(num); if(prime==1) printf(%d is a prime number,num); else printf(%d is not a prime number,num); return 0; } int isPrime(int num){ int i=2; while(i
Posted on: Thu, 16 Jan 2014 06:52:01 +0000

Trending Topics



Recently Viewed Topics




© 2015