## Pages

### Data Structure Heap Algorithms MCA Sem 2

Data Structure Algorithm for  Heap Operations  pseudo-code.
After knowing and completely understanding this algorithm for  Heap Operations . You will be able to write a Data Structure Programs for  Heap Operations  in any language. The basic ideology and idea behind all the programs will be same. Yes the programs will differ according to the syntax and semantics of the language. This is a part of Mumbai University MCA Colleges Data Structure MCA Sem 2

ReheapUp:-

Algorithm ReheapUp(heap, newNode)
1 if(newNode <> 0) (* if not root of heap *)
1 parent := (newNode-1)/2
2 if (heap[newNode]>heap[parent]) (* child greater than parent *)
1 hold = heap[parent]
2 heap[parent] = heap[newNode] (* exchange *)
3 heap[newNode] = hold
4 ReheapUp (heap, parent) (*continue reheapUP *)
3 end if
2 end if
End ReheapUp

Heap Insertion:-

Algorithm InsertHeap(heap, last, data) : BOOLEAN
1 if (last = HeapSize -1)
1 return FALSE (* over the heap size limitation *)
2 increment last (* increase the size of the heap *)
3 heap[last] = data (* put the data at the last position *)
4 ReheapUp(heap, last) (* restore the heap *)
5 return TRUE
End InsertHeap

ReheapDown:-

Algorithm ReheapDown (heap, root, last)
1 if ((root*2 +1) <= last) (* There is at least left child *)
2 leftKey := heap[root*2 +1] (* left child value *)
3 rightChild := FALSE (* assume no right child)
1 if ((root*2 + 2) <= last) (* There is also right child *)
1 rightKey := heap[root*2 +2] (* right child value *)
2 rightChild := TRUE
2 end if
3 largeChildKey := leftKey;
4 largeChildIndex := root*2 + 1; (* assume left child larger *)
5 if (rightChild AND leftKey < rightKey)
1 largeChildKey := rightKey; (* right child exists and is larger *)
2 largeChildIndex := root*2 +2;
6 end if
7 if (heap[root] < largeChildKey) (* exchange larger child with root *)
1 hold := heap[root];
2 heap[root] := heap[largeChildIndex];
3 heap[largeChildIndex] := hold;
4 reheapDown (heap, largeChildIndex, last);
8 end if
2 end if
end ReheapDown
Heap Deletetion

Algorithm DeleteHeap(heap, last, dataOut)
1 if (last < 0) (* empty heap *)
1 return FALSE
2 dataOut := heap (* remove the largest data at root *)
3 heap := heap[last] (* restore the shape *)
4 decrement last
5 reheapDown (heap, 0, last) (* restore the order property *)
6 return TRUE
End DeleteHeap

Algorithm for converting to max heap:-

Algorithm CreateHeap(list)
1 set index to 1
2 loop (index <= listLength)
1 reheapUp(list, index)
2 increment index
3 end loop
End CreateHeap

Heap Sort Algorithm:-

Algorithm HeapSort(list, last)
(* Create a heap *)
1 CreateHeap(list)
2 sorted := last;
3 loop (sorted > 0)
1 holdData := list (* exchange 0 and sorted *)
2 list := list[sorted]
3 list[sorted] = holdData
4 decrement sorted
5 reheapDown (list, 0, sorted);
4 end loop
End HeapSort

Hope this Algorithm is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Data Structure Binary Search Algorithm

Data Structure Algorithm for  Binary Search pseudo-code.
After knowing and completely understanding this algorithm for  Binary Search . You will be able to write a Data Structure Program for  Binary Search  in any language. The basic ideology and idea behind all the programs will be same. Yes the programs will differ according to the syntax and semantics of the language. This is a part of Mumbai University MCA Colleges Data Structure MCA Sem 2

Algorithm Binary(list, from, to, target, location)
1 if from = to (* terminating condition *)
1 set location to from
2 return list[from] = target
2 end if
3 middle := (to – from) DIV 2;
4 if list[middle] = target (* found target *)
1 set location to middle
1 return TRUE
5 else
1 if list[middle] < target (* select second half *)
1 set found to Binary(list, middle+1, to, target, location)
2 else (* select first half *)
1 set found to Binary(list, from, middle-1, target, location)
3 end if
6 end if
7 return found
end Binary

Hope this Algorithm is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Data Structure Quick Sort Algorithm

Data Structure Algorithm for  Quick sort  pseudo-code.

After knowing and completely understanding this algorithm for  Quick sort . You will be able to write a Data Structure Program for  Quick sort  in any language. The basic ideology and idea behind all the programs will be same. Yes the programs will differ according to the syntax and semantics of the language. This is a part of  Mumbai University MCA Colleges Data Structure MCA Sem 2

Algorithm QuickSort(list, left, right) (* Assume the list is not empty. *)
1 set pivot to Median(left, right, middle)
2 set sortLeft to left+1
3 set sortRight to right
4 loop sortLeft <= sortRight
1 loop [sortLeft] < [pivot]
1 increment sortLeft
2 end loop
3 loop [sortRight] >= [pivot]
1 decrement sortRight
4 end loop
5 if sortLeft < sortRight
1 exchange( sortLeft, sortRight)
2 increment sortLeft
3 decrement sortRight
6 end if
5 end loop
6 exchange(pivot, sortLeft-1) (* return the pivot into correct location *)
(* start left partition sort *)
7 if left < pivot
1 quickSort(list, left, pivot-1)
8 end if
(* start right partition sort *)
9 if right > pivot
1 quickSort(list, pivot+1, right)
10 end if
End QuickSort

Hope this Algorithm is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Data Structure Sequential Search Algorithm.

Data Structure Algorithm for  Sequential Search  pseudo-code.
After knowing and completely understanding this algorithm for  Sequential Search . You will be able to write a Data Structure Program for  Sequential Search  in any language. The basic ideology and idea behind all the programs will be same. Yes the programs will differ according to the syntax and semantics of the language. Mumbai University MCA College Algorithm

Algorithm SeqSearch(list, last,target,location)
1 set current to 0
2 set found to FALSE
3 loop (current < endList AND
list[current] <> target)
1 increment current
4 end loop
5 set location to current
6 if (list[current] = target)
1 set found to TRUE
7 end if
End SeqSearch

Hope this Algorithm is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Data Structure Shell Sort Algorithm MCA Sem 2

Data Structure Algorithm for Shell sort pseudo-code.

After knowing and completely understanding this algorithm for Shell sort. You will be able to write a Data Structure Program for Shell sort in any language. The basic ideology and idea behind all the programs will be same. Yes the programs will differ according to the syntax and semantics of the language. This is a part of Mumbai University MCA Colleges Data Structure MCA Sem 2

Algorithm ShellSort(list) (* Assume the list is not empty. *)
1 set increment to half the list length
2 loop (* for each value of increment *)
1 …
2 loop (* for each segment *)
1 …
2 loop (* for finding the correct position for each element *)
1 …
2 store the element in correct position
3 end loop
4 move to next segment
3 end loop
4 set increment to increment/2
3 end loop
End ShellSort

Hope this Algorithm is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Data Structure Insertion Sort Algorithm

Data Structure Algorithm for Straight Insertion sort pseudo-code.
After knowing and completely understanding this algorithm for Insertion sort. You will be able to write a Data Structure Program for Insertion sort in any language. The basic ideology and idea behind all the programs will be same. Yes the programs will differ according to the syntax and semantics of the language.
This algorithm is a part of Mumbai University MCA Colleges Data Structure MCA Sem 2.

Algorithm InsertionSort(list) (* Assume the list is not empty. *)
1 set listWall to startList (* listWall points to start of unsorted list *)
2 loop while listWall <= endList
1 set hold to listWall
2 set current to listWall prev
(* scan the sorted list moving larger elements to right *)
3 loop while (current > startList) AND hold key < current key
1 move current to current next
3 set current to current prev
4 end loop (* found the insertion point *)
5 move hold to current next
7 set listWall to listWall next
3 end loop
End InsertionSort

Hope this Algorithm is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### GCD (Greatest Common Divisor) of 2 numbers using Recursion C program

This program displays the GCD ( Greatest Common Divisor) of 2 numbers using Recursion. This is a part of Mumbai University MCA Colleges C Program MCA

#include<stdio.h>
#include<conio.h>

void main()
{
int gcd(int num1,int num2,int n);
int num2,num1,n,ans;
clrscr();

printf("\n Enter two numbers");
scanf("%d %d",&num1,&num2);

if(num1> num2)                         /* select the limit for the divisor */
n=num1/2;
else
n=num2/2;

ans=gcd(num1,num2,n);
printf("GCD of %d and %d is %d",num1,num2,ans);
getch();
}

int gcd(int num1,int num2,int n)
{
if(n==1)                      /*if divisor is 1 */
return(1);
else
{                                   /* find if n divides both the numbers */
if(num1%n==0 && num2%n==0)
return(n);
else                            /*check the numbers with next values */
gcd(num1,num2,(n-1));
}
}

OUTPUT:

Enter two numbers           36         45

GCD of 36 and 45 is 9

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C Program Decimal to Binary Fraction Conversion

This programs calculates the Decimal fraction equivalent of a Decimal number using Array. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
double z,doub,r,n,count=0,i=0,frac;
int num,p,ar;
clrscr();
printf("Enter the number to convert");
scanf("%lf",&doub);
num=doub;
frac=doub-num;
while(num!=0)
{
ar[i]=num%2;
num=num/2;
i++;
count++;
}

printf("The Binary form of this number is ");
for(i=(count-1);i>=0;i--)
{
printf("%d",ar[i]);
}
printf(".");
while(frac!=0)
{
z=frac*2;
p=z;
frac=z-p;
printf("%d",p);
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program calculate seconds from days

This program calculates the number of days in a given date. This is a part of Mumbai University MCA Colleges C programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
int y,m,d;
long float sec,total;
clrscr();
printf("Enter the year");
scanf("%d",&y);
printf("Enter the month");
scanf("%d",&m);
printf("Enter the days");
scanf("%d",&d);
total=(365*y)+(30*m)+d;
sec=total*24*60*60;

printf("The number of seconds is %lf",sec);
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program Compound interest using simple interest

This program calculates the  Compound interest using simple interest function. This is a part of Mumbai University MCA Colleges C Program MCA Sem 1

#include<stdio.h>
#include<conio.h>
double simpint(double,double);
void main()
{
double p,amt,r,n;
int i;
clrscr();
printf("Enter the principle amount\n");
scanf("%lf",&p);
printf("Enter the rate of interesnt\n");
scanf("%lf",&r);
printf("Enter the years\n");
scanf("%lf",&n);

for(i=1;i<=n;i++)
{
amt=simpint(p,r);
p=p+amt;
}
printf("The compund interest after %lf years is %lf",n,p);
getch();
}
double simpint(double p,double r)
{
return((p*r)/100);
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program percent-grade of students.

This C program finds the percentage of students marks and classifies them according to percentage. This is a part of Mumbai University MCA Colleges C programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float m1,m2,m3;
float per;
printf("Enter the marks of three subjects out of 100");
scanf("\n %f %f %f",&m1,&m2,&m3);
if(m1<0 || m2<0 || m3<0)
{
printf("Marks cant be negetive");
}
else
{
if(m1<35 || m2<35 || m3<35)
{
printf("You have failed");
}
else
{
per=(m1+m2+m3)/3;
if(per>=75)
{
printf("You got distinction with %f percentage",per);
}
else if (per>=60)
{
printf("You got a 1st class with %f percentage",per);
}
else if(per>=45)
{
printf("You got 2nd class with %f percentage",per);
}
else
{
printf("You got pass class with %f percentage",per);
}
}
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program binary fraction to decimal conversion

This program converts a Binary Fraction to a Decimal Fraction. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
double ans,bin,frac,fun=0.0,a;
int sum=0,dec,i=0,rem,b,j=1;
printf("\nEnter the Binary number");
scanf("%lf",&bin);
dec=bin;
frac=bin-dec;
while(dec!=0)
{
rem=dec%10;
dec=dec/10;
sum=sum+(rem*pow(2,(i++)));
}
while(frac!=0.000)
{
a=10*frac;
b=a;
fun=fun+(b*(1/pow(2,(j++))));
frac=a-b;
}
ans=sum+fun;
printf("\nThe decimal equivalent is %lf",ans);
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program Binary to Decimal conversion

This Program converts a Binary number to a decimal number. This is a part of Mumbai University MCA Colleges C program MCA Sem 1

#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int sum=0,bin,i=0,rem;
printf("\n Enter binary number:");
scanf("%d",&bin);
while(bin!=0)
{
rem=bin%10;
bin=bin/10;
sum=sum+(rem*pow(2,(i++)));
}
printf("\nThe decimal equivalent is %d",sum);
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program replace vowel in string

This C program accepts a string of min 15 characters. Replace all the vowels in the string with the character ‘*’. Do not use any standard library function. This is a part of Mumbai University MCA Colleges C Program MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
char st1;
int i;
clrscr();
printf("Enter any string");
scanf("%s",st1);
while(s1[i]!=’\0’)
{
len++l
i++;
}
if(len<=15)
printf(“Plz, Enter more than 15 characters”);
else
{
for(i=0;i<15;i++)
{
if(st1[i]=='a' || st1[i]=='e' || st1[i]=='i' || st1[i]=='o' || st1[i]=='u' || st1[i]==’A’ || st1[i]==’E’ || st1[i]==’I’ || st1[i]==’O’ || st1[i]==’U’)
{
st1[i]='*';
}
}
}
printf("\n After replacing vowels by * string will be %s",st1);
getch();

}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Decimal to Binary Conversion using Recursion

This program converts the Decimal number to Binary Using Recursion. This is a part of Mumbai University MCA Colleges C Program MCA

#include<stdio.h>
#include<conio.h>
void main()
{
int n;
void convert(int num);
clrscr();

printf("Enter the decimal integer : ");
scanf("%d",&n);

printf("Binary equivalent is : ");
convert(n);
getch();
}

void bin_convert(int num)
{
int r;
if(num>0)
{
r=num%2;
num=num/2;
convert(num);
printf("%d",r);
}
}

OUTPUT:

Enter the decimal integer:       9

Binary equivalent is:    1001

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### String Reverse using Recursion C Program

This program is for Reversing a String Using Recursion. This is a part of Mumbai University MCA Colleges C Program and Data Structure MCA

#include<stdio.h>
#include<conio.h>
void revstring(char[],int);

void main()
{
char str;
clrscr();

/* accept a string from the user */
printf("\n Enter the string\n");
fflush(stdin);
gets(str);

/*print the original string */
printf("\n original string: %s\n",str);

printf("\n Reversed string: ");
revstring(str,0);
getch();
}

void revstring(char str[],int n)
{
/* check for null string */
if(str[n]=='\0')
return;

revstring(str,n+1);
printf("%c",str[n]);
}

OUTPUT:

Enter the string:       Data Structures

Original String:         Data Structures

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C++ Program Write Object on File

This is a Cpp (C++) program for file handling which stores a object on a file. This file stores the student details from the student class object directly by writing the object onto the file. This is also called serialization.
This is a part of Mumbai University MCA Colleges C++ MCA Sem 3

#include<stdio.h>
#include<conio.h>
#include<math.h>
class Student
{
int roll_no;
char cname;
public:
void setrollno()
{
cout<<"Enter the rollno:"<<endl;
cin>>roll_no;
}
void setname()
{
cout<<"\nEnter name:"<<endl;
cin>>cname;
}
int getno()
{
return roll_no;
}
char * getname()
{
return cname;
}
};
void main()
{
clrscr();
ofstream sfil("STUDENT");
Student st;
st.setrollno();
st.setname();
sfil<<st.getno();<<' ';
sfil<<st.getname();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C++ Program File Handling Read/Write

This is a simple File Handling Program in C++ for writing and reading a file using streams. This is a part of Mumbai University MCA Colleges Cpp MCA Sem 3

#include<iostream.h>
#include<fstream.h>
#include<math.h>
void main()
{
clrscr();
ofstream fout("Myfile");
fout<<"Ganesh";
fout.close();
ifstream fin("Myfile");
char ch;
while(fin)
{
fin.get(ch);
cout<<ch;
}
fin.close();
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Converting Number to Words Javascript Indian Format

#### The Below code is used for number to words conversion ( Indian Format). The logic used can be implement in any other language. I have used java script here but if you understand the logic then you can recreate it using any other language.

Enter the Number here.

The Code for the above logic is as follows.

<script language="javascript">

function numToString(x)
{
var r=0;
var txter=x;
var sizer=txter.length;
var numStr="";
if(isNaN(txter))
{
exit();
}
var n=parseInt(x);
var places=0;
var str="";
var entry=0;
while(n>=1)
{
r=parseInt(n%10);

if(places<3 && entry==0)
{
numStr=txter.substring(txter.length-0,txter.length-3) // Checks for 1 to 999.
str=onlyDigit(numStr); //Calls function for last 3 digits of the value.
entry=1;
}

if(places==3)
{
numStr=txter.substring(txter.length-5,txter.length-3)
if(numStr!="")
{
str=onlyDigit(numStr)+ " Thousand "+str;
}
}

if(places==5)
{
numStr=txter.substring(txter.length-7,txter.length-5) //Substring for 5 place to 7 place of the string
if(numStr!="")
{
str=onlyDigit(numStr)+ " Lakhs "+str; //Appends the word lakhs to it
}
}

if(places==6)
{
numStr=txter.substring(txter.length-9,txter.length-7)  //Substring for 7 place to 8 place of the string
if(numStr!="")
{
str=onlyDigit(numStr)+ " Crores "+str;        //Appends the word Crores
}
}

n=parseInt(n/10);
places++;
}
}

function onlyDigit(n)
{
//Arrays to store the string equivalent of the number to convert in words
var units=['','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'];
var randomer=['','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'];
var tens=['','Ten','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'];
var r=0;
var num=parseInt(n);
var str="";
var pl="";
var tenser="";
while(num>=1)
{
r=parseInt(num%10);
tenser=r+tenser;
if(tenser<=19 && tenser>10) //Logic for 10 to 19 numbers
{
str=randomer[tenser-10];
}
else
{
if(pl==0)        //If units place then call units array.
{
str=units[r];
}
else if(pl==1)    //If tens place then call tens array.
{
str=tens[r]+" "+str;
}
}
if(pl==2)        //If hundreds place then call units array.
{
str=units[r]+" Hundred "+str;
}

num=parseInt(num/10);
pl++;
}
return str;
}

</script>

<form name="fm" id="fm">

<input type="text"  name="txtinput" id="txtinput" maxlength="9" />
<input type="button" onclick="numToString(txtinput.value)" id="show" />

</form>

### C Program Leap Year MCA Sem 1

This C program finds if the input year is a Leap Year or not. This is a part of Mumbai University MCA Colleges C programs MCA Sem 1.
Leap year is any year which is divisible by 4.

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
clrscr();
int year;
printf("Enter the year to find if it is leap year or not:");
scanf("%d",&year);
if(year%4==0&&year%100!=0||year%400==0)
{
printf("The year entered is a leap year.");
}
else
{
printf("The year entered is not a leap year.");
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C Program Keypress identification MCA Sem 1

This C program take in a Key Press and displays if its a number , character (small or Big) or Special character. This program is part of Mumbai University MCA Colleges C programs MCA Sem 1.
This program uses the concepts of ASCII values on the keyboard press.

#include<stdio.h>
void main()
{
char c,ans;
do{
fflush(stdin);
printf("Enter character");
scanf("%c",&c);
if(c>=65 && c<=90)
{
printf("Entered character is capital letter");
}
if(c>=97 && c<=122)
{
printf("SMALL LETTERS");
}
if(c>=48 && c<=57)
{
printf("DIGIT");
}
if(c>=32 && c<=47)
{
printf("SPECIAL CHARACTER");
}
fflush(stdin);
printf("do u want to continue y/n");
scanf("%c",&ans);
}
while(ans!='n');
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C program Number to Text 2 conversion

This C program will convert the number to words in tens and units place respectively. This is a part of Mumbai University MCA Colleges C programs MCA Sem 1
Out put as

Input:- 12345
Output:- twelve thousand three hundred fourty five

#include<stdio.h>

void pw(long,char[]);//function
char *unit[]={" "," one"," two"," three"," four"," five"," six"," seven","eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","seventy"," eighty"," ninety"};

void main()
{
long n;
printf("Enter any 9 digit no: ");
scanf("%9ld",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
pw((n/10000000),"crore");//Will give either 1 or 2 digit answer
pw(((n/100000)%100),"lakh");//Will give either 1 or 2 digit answer
pw(((n/1000)%100),"thousand");//Will give either 1 or 2 digit answer
pw(((n/100)%10),"hundred");//Will always give 1 digit answer
pw((n%100)," ");////Will give always 2 digit answer
}
}

void pw(long n,char ch[])
{
(n>19)?printf("%s %s ",ten[n/10],unit[n%10]):printf("%s ",unit[n]);
/*This if condition will execute if n is greater than 0 and used to print crore, lakh, thousand and hundred
This is used so that if say we enter 12000 the answer must be "twelve thousand"
If you omit the if statement and simply write the print statement the output would be like
"twelve thousand hundred" which is not the right one
*/
if(n)
printf("%s ",ch);
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### C Program Triangle Area 2 Methods

This C program finds the area of Triangle using 2 methods. This is a part of Mumbai University MCA College C Programs MCA Sem 1.

The area of triangle can be found by knowing its height and width or by knowing the length of all side.

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{ clrscr();
float bs,ht,a,b,c,s;
float area;
int k;
printf("If you want to use base n height method then enter 1\n");
printf("If you want to use sides method then enter 2\n");
scanf("%d",&k);
switch(k)
{
case 1:
printf("Enter the base and the height of the triangle:");
scanf("%f%f",&bs,&ht);
area=0.5*bs*ht;
break;

case 2:
printf("Enter the three sides of the triangle:");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
break;
}
printf("The area of the triangle is:%f",area);
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.