# Day: January 24, 2021

#### Function Passing no Arguments and Returning no Value

January 24, 2021

Write a program to functions to passing no arguments an returning no values. #include <stdio.h>#include <conio.h>void sum (void);void main(){ sum(); getch();}void sum(void){ int add, a, b; printf(“Enter two numbers:”); scanf(“%d%d”,&a,&b); add=a+b; printf(“n the sum is %d”,add);} Output

#### Function Passing no Arguments and Returning Values

January 24, 2021

This program describes how to write function passing no arguments and returning values. #include <stdio.h>#include <conio.h>int sum (void);void main(){ int c; c=sum(); printf(“n The sum of two numbers is : %d”,c); getch();}int sum(void){ int add, a, b; printf(“Enter two numbers:”); scanf(“%d%d”,&a,&b); add=a+b; return(add);} Output

#### Function Passing Arguments and Returning no Value

January 24, 2021

This C program describes how to write a code for function passing arguments and returning no value. #include <stdio.h>#include <conio.h>void sum (int, int);void main(){ int a,b; printf(“enter two numbers :”); scanf(“%d%d”,&a,&b); sum(a,b); getch();}void sum(int s, int t){ int add; add = s+t; printf(“n The sum of the two numbers is : %d”, add); } Output

#### C program to find the sum of n integer numbers using the function

January 24, 2021

Write a c program to find the sum of the N integer numbers using the fuctions. #include <stdio.h>#include <conio.h>int sum (int number);void main(){ int n; printf(“How many number : “); scanf(“%d”, &n); printf(“sum the %d numbers is : %d “,n,sum(n)); getch();}int sum(int number){ int i, add=0; for(i=1; i<=number; i++){ add+=i; } return add;} Output

#### C program to find prime number from 1 to 100 numbers using the function

January 24, 2021

Find prime number from 1 to 100 numbers using the function on C program. #include <stdio.h>#include <conio.h>int primenumber (int number);void main(){ int i; printf(“given numbers are prime numbers :n”); for(i =1; i<=100; i++) { if(primenumber(i)) printf(“%dt”,i); } getch();}int primenumber(int number){ int i, flag=1; for(i=2; i<=number/2; i++){ if(number%i==0) flag = 0; } return flag;} Output

#### Function Passing Arguments and Returning Value

January 24, 2021

This program describes that function passing arguments and returning value. #include <stdio.h>#include <conio.h>int sum (int, int);void main(){ int a,b,c; printf(“enter two numbers :”); scanf(“%d%d”,&a,&b); c = sum(a,b); printf(“n the sum of two numbers is : %d”, c); getch();}int sum(int s, int t){ int add; add = s+t; return (add); } Output

#### C Program to find the factorial of the entered number using recursive function

January 24, 2021

This program explains how to find factorial of the entered number using recursive function. #include <stdio.h> #include <conio.h> int factorial (int); void main() { int number; printf(“enter a numbers :”); scanf(“%d”,&number); printf(“n the factorial of the entered number %d is : %d”,number, factorial(number)); getch(); } int factorial(int number){ if (number<=1) return(1); else return(number*factorial(number-1)); } Output

#### C program to check the entered number is exactly divisible by 5 but not 11

January 24, 2021

Write a program that checks whether the number entered by the user is exactly divisible by 5 but not by 11.  C Code #include <stdio.h>#include <conio.h>#include <math.h>void main(){ int number; printf(“enter number:”); scanf(“%d”, &number); if(number%5==0 && number%11!=0) printf(“%d is divisible by 5 but not by 11”, number); else printf(“condition is not satisfied”); getch();} Output

#### C Program to find the square root of the number using the function.

January 24, 2021

Write a c program to find the square root of the number.  #include<stdio.h>#include<conio.h>#include<math.h>void main(){ int num; int squreroot(int num); printf(“Input Number:”); scanf(“%d”,&num); squreroot(num); getch();}int squreroot(int num){ printf(“squreroot: %f”,sqrt(num)); return 0; }