Monthly Archives: November 2017


Write a program to find the largest element in an array using Recursion – IGNOU MCA Assignment 2017 – 18

MASTER OF COMPUTER APPLICATIONS
Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2017-18
Maximum Marks : 100

Write a program to find the largest element in an array using Recursion – IGNOU MCA Assignment 2017 – 18

 Program:

#include<stdio.h>
int LARGE=-1;
void main()
{
int NUM[10],I;
void largest_rec(int *);
clrscr();
printf(“ENTER TEN NUMBERS TO COMPARE\n”);
for(I=0;I<10;I++)
{
printf(“\nENTER NUMBER : “);
scanf(“%d”,&NUM[I]);
}
largest_rec(NUM);
printf(“\nTHE LARGER NUMBER IS %d”,LARGE);
getch();
}

void largest_rec(int *TEMP)
{
if(*TEMP)
{
if(LARGE<*TEMP)
LARGE=*TEMP;
largest_rec(TEMP+1);
}
}

Code:

#include<stdio.h>
int LARGE=-1;
void main()
{
int NUM[10],I;
void largest_rec(int *);
clrscr();
printf("ENTER TEN NUMBERS TO COMPARE\n");
for(I=0;I<10;I++)
{
printf("\nENTER NUMBER : ");
scanf("%d",&NUM[I]);
}
largest_rec(NUM);
printf("\nTHE LARGER NUMBER IS %d",LARGE);
getch();
}
void largest_rec(int *TEMP)
{
if(*TEMP)
{
if(LARGE<*TEMP)
LARGE=*TEMP;
largest_rec(TEMP+1);
}
}

Screen Shots:

C_program_Largest_Recursion

C_program_Largest_Recursion_Output

A C program to separate even and odd of array put them in two arrays – IGNOU MCA Assignment 2017 – 18

MASTER OF COMPUTER APPLICATIONS
Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2017-18
Maximum Marks : 100

Write a C program to separate even and odd numbers of an array and put them in two arrays.- IGNOU MCA Assignment 2017 – 18

 

Program:

#include<stdio.h>
void main()
{
int I,J=0,K=0,NUM[]={1,2,3,4,5,6,7,8,9,10},EVEN[10],ODD[10];
clrscr();
printf(“\nNUMBERS IN AN ARRAY ARE : \n”);
for(I=0;I!=10;I++)
printf(“%d\t”,NUM[I]);
for(I=0;I!=10;I++)
{
if(NUM[I]%2==0)
{
EVEN[J++]=NUM[I];
}
else if(NUM[I]%2!=0)
{
ODD[K++]=NUM[I];
}
}
EVEN[J]=ODD[K]=NULL;
printf(“\nTOTAL EVEN NUMBER ARE : \n”);
for(I=0;EVEN[I]!=NULL;I++)
printf(“%d\t”,EVEN[I]);
printf(“\n”);
printf(“\nTOTAL ODD NUMBER ARE : \n”);
for(I=0;ODD[I]!=NULL;I++)
printf(“%d\t”,ODD[I]);
getch();
}

Code:

#include<stdio.h>
void main()
{
int I,J=0,K=0,NUM[]={1,2,3,4,5,6,7,8,9,10},EVEN[10],ODD[10];
clrscr();
printf("\nNUMBERS IN AN ARRAY ARE : \n");
for(I=0;I!=10;I++)
printf("%d\t",NUM[I]);
for(I=0;I!=10;I++)
{
if(NUM[I]%2==0)
{
EVEN[J++]=NUM[I];
}
else if(NUM[I]%2!=0)
{
ODD[K++]=NUM[I];
}
}
EVEN[J]=ODD[K]=NULL;
printf("\nTOTAL EVEN NUMBER ARE : \n");
for(I=0;EVEN[I]!=NULL;I++)
printf("%d\t",EVEN[I]);
printf("\n");
printf("\nTOTAL ODD NUMBER ARE : \n");
for(I=0;ODD[I]!=NULL;I++)
printf("%d\t",ODD[I]);
getch();
}

Screen Shots:

C_program_Separate_Even_Odd

C_program_Separate_Even_Odd_output

A C program to convert an octal number to its equivalent decimal number – IGNOU MCA Assignment 2017 – 18

MASTER OF COMPUTER APPLICATIONS
Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2017-18
Maximum Marks : 100
Weightage : 25%

Draw a flow chart and write its corresponding C program to convert an octal number to its equivalent decimal number.- IGNOU MCA Assignment 2017 – 18

 

Flowchart:

FlowChart_Octal_2_Decimal

#include<stdio.h>
#include<math.h>
void main ()
{
int oct,dec=0,i=0;
clrscr();
printf(“Enter any Octal number : “);
scanf(“%d”,&oct);
while(oct!=0)
{
dec=dec+(oct%10)*pow(8,i++);
oct=oct/10;
}
printf(“Decimal = %d\n”, dec);
getch();
}

Code:

#include<stdio.h>
#include<math.h>
void main ()
{
int oct,dec=0,i=0;
clrscr();
printf("Enter any Octal number : ");
scanf("%d",&oct);
while(oct!=0)
{
dec=dec+(oct%10)*pow(8,i++);
oct=oct/10;
}
printf("Decimal = %d\n", dec);
getch();
}

Screen Shots:

C_program_Octal_to_Decimal

C_program_Octal_to_Decimal_Output