Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Tuesday, 2 April 2013

Check Armstrong Number in Java Programming


Armstrong Number : A number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.
For example 153 is an Armstrong number since 1*1*1 + 5*5*5 + 3*3*3 = 153
In Java Programming We design a code which determine whether given number is Armstrong Number or Not.


Source Code :



<pre class="brush: java">
class arm
{int armstrong(int n)
{
if(n==0)
return n;
else 
return (n%10)*(n%10)*(n%10)+armstrong(n/10);
}
public static void main(String ar[])
{
arm a=new arm();
int x,y=153;
x=a.armstrong(y);
if(x==y)
{
System.out.println("Given  No. "+y+" is a Armstrong No.");
}
else
{
System.out.println("Given  No. "+y+" is Not a Armstrong No.");
}
}
}
</pre>



Output :




Monday, 25 March 2013

Round Robin Scheduling in C Programming

Round Robin Technique is one of the scheduling algorithm for processes in an operating system. This algorithm give the CPU access to a process for a particular time period which time know as Quantum Time. After execution once all the process again repeated and allotted for CPU execution that’s why it’s Round term us in this algorithm. I made following Program which manage all the process and calculate average turn around time and waiting time.

Source Code :

<pre class="brush : cpp">
#include<stdio.h>
#include<conio.h>
int main()
{
int st[10], bt[10], wt[10], tat[10], n, tq;
int i, count=0, swt=0, stat=0, temp, sq=0;
float awt=0.0, atat=0.0;
printf("enter number of processes : ");
scanf("%d", &n);
printf("nenter burst time for processes ");
for(i=0; i<n;i++)
{
printf("nFor process p%d : ",i+1); 
scanf("%d", &bt[i]);
st[i]=bt[i];
}
printf("nenter time quantum : ");
scanf("%d", &tq);
while(1)
{
for(i=0, count=0;i<n;i++)
{
temp=tq;
if(st[i]==0)
{
count++;
continue;
}
if(st[i]>tq)
{
st[i]=st[i]-tq;
}
else
if (st[i]>=0)
{
temp=st[i];
st[i]=0;
}
sq=sq+temp;
tat[i]=sq;
}
if(n==count)
break;
}
for(i=0;i<n;i++)
{
wt[i]=tat[i]-bt[i];
swt=swt+wt[i];
stat=stat+tat[i];
}
awt=(float)swt/n;
atat=(float)stat/n;
printf(" n process_not burst_timet wait_timet turn_around_time");
for(i=0; i<n; i++)
{
printf("n%dtt %dtt %dtt %d", i+1, bt[i], wt[i], tat[i]);
}
printf("naverage wait time is %fnaverage turn_around_time is %fn", awt, atat);
getch();
return 0;}
</pre>


Output :




Saturday, 5 January 2013

CodingTalks - Sharpen Your Programming Skills

Welcome to Coding Talks.



Coding Talks a platform which programmer can talk with programmers. Our main tarket to provide programming solution like Discussion , Tutorial , Projects Help Etc.

We ll help to improve your programming Skills.