Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Name: Shenise Naene 香妮

Student ID: 2020030223

Subject: C Programming Language

Chapter NO: 15

Assignment NO: 13

Date: 29/06/2021

Source code Program 1

#include <stdio.h>

int fun(int n)

if(n==0) {

return 1;

else

return 7 + fun(n-2);

int main()

printf("%d", fun(4));

return 0;

Output
Source code program 2

#include <stdio.h>

int fact(int n)

if(n==1) {

return 1;

else

return n*fact(n-1);

int main()

{
int n;

printf("Enter the number: ");

scanf("%d", &n);

printf("Factorial of a number %d is %d", n, fact(n));

Output

Source code program 3

void odd();

void even();

int n=1;

void odd()

if(n <= 10) {


printf("%d", n+1);

n++;

even();

return;

void even()

if(n<=10) {

printf("%d", n-1);

n++;

odd();

return;

int main()

odd();

Output
Source code program 4

#include <stdio.h>

void fun(int n) {

if(n==0)

return;

else

printf("%d", n);

return fun(n-1);

int main() {

fun(3);

return 0;

Output

You might also like