# Write an interactive C program which illustrates the following concepts – IGNOU MCA Assignment 2015 – 16

By | September 8, 2015

MASTER OF COMPUTER APPLICATIONS

Course Code : MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(I)/011/Assignment/15-16
Maximum Marks : 100
Weightage : 25%

Write an interactive C program which illustrates the following concepts:

(i) Function with no arguments and no return value.

(ii) Function with arguments and no return value.

(iii) Function with arguments and with return value.

Write an interactive C program which illustrates the following concepts:

(i) Function with no arguments and no return value.

code:-

#include<stdio.h>
void main()
{
void factorial(int);
int NUM;
clrscr();
printf(“ENTER NUMBER : “);
scanf(“%d”,&NUM);
factorial(NUM);
getch();
}
void factorial(int N)
{
int I,FACT=1;
printf(“ENTER NUMBER : “);
scanf(“%d”,&N);
for(I=N;I>0;I–)
FACT=FACT*I;
printf(“\nFACTORIAL OF GIVEN NUMBER IS %d “,FACT);
}

ScreenShot:-

(ii) Function with arguments and no return value.

code:-

#include<stdio.h>
void main()
{
void factorial(int);
int NUM;
clrscr();
printf(“ENTER NUMBER : “);
scanf(“%d”,&NUM);
factorial(NUM);
getch();
}
void factorial(int N)
{
int I,FACT=1;
for(I=N;I>0;I–)
FACT=FACT*I;
printf(“\nFACTORIAL OF GIVEN NUMBER IS %d “,FACT);
}

ScreenShot:-

(iii) Function with arguments and with return value.

code:-

#include<stdio.h>
void main()
{
int factorial();
int FACT,NUM;
clrscr();
printf(“ENTER NUMBER : “);
scanf(“%d”,&NUM);
FACT=factorial(NUM);
printf(“\nFACTORIAL OF GIVEN NUMBER IS %d “,FACT);
getch();
}
int factorial(int N)
{
int RESULT=1,I;
for(I=N;I>0;I–)
RESULT=RESULT*I;
return(RESULT);
}

ScreenShot:-

Output (Common for ALL):-