Showing posts with label turbo c. Show all posts
Showing posts with label turbo c. Show all posts

Wednesday, 6 April 2016

How To Identify Armstrong Numbers Using Turbo C Compiler

According to illuminations.nctm.org, an Armstrong number is an n-digit number that is equal to the sum of the nth powers of its digits.
To have a clearer understanding of what an Armstrong number is, I have prepared below a solution on how to determine if a number is an Armstrong or not.

#include<math.h>

#include<stdio.h>
void armstrong(void);
main()
{
clrscr();
armstrong();
getch();
}
void armstrong(void)
{
long count=0,m,n,m1,q,r,a,b,sum=0;
scanf("%ld",&n);
m=n;
m1=n;
for(;n!=0;)
{
r=n/10;
count++;
n=r;
}
for(;m!=0;)
{
a=m/10;
b=m%10;
sum=sum+ pow(b,count);
m=a;
}
if(sum==m1)
{
printf("Armstrong");
}
else
{
printf("Not");
}
}


How To Identify Happy Numbers Using Turbo C Compiler

What are happy numbers?

According to Wikipedia...
happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers).

Using Turbo C compiler for the C programming language...


#include<stdio.h>
void happynumber(void);
main()
   {
   clrscr();
   happynumber();
   getch();
   }

void happynumber(void)
   {
   int n,q,r,t=0,i;
   scanf("%d",&n);

  for(i=1;i<1000;i++)
   { t=0;
     for(;;)
       {
       q=n/10;
       r=n%10;
       t=t+(r*r);
       if(q==0)
{
n=t;
break;
}
n=q;
}
     }
   if(t==1)
      {
      printf("happy number");

      }
   else
      {
      printf("not");
      }



   }




Wednesday, 30 September 2015

HOW TO SETUP TURBO C ON LINUX UBUNTU OPERATING SYSTEM

Turbo C can't run on Windows 64-bit OS without the aid of DOSBox emulator.
Since we are now in the Linux environment, some of you might ask what to do to run Turbo C, that is why I decided to make this tutorial.

In this tutorial, we will use DOSBox Emulator. Just download it on the Software Center.



Dowload the Turbo C files HERE.   (I do not own these files)
 
Unzip the zipped file.

Inside it is a "tc" folder. 

Just copy/move it to this directory home/user_name



Now, open DOSBox Emulator.


To mount C drive, type these

MOUNT C: ~/



To make C drive as the current directory, type these

C:


To change directory, type these
CD TC


To open TC, type these
TC 





To access the menu bar, press F10.
Cheers!