Tuesday, August 10, 2010

SIMPLE CALCULATOR

0 comments
#include<stdio.h> #include<conio.h> #include<math.h> void main() { char opr; int a,b; float result=0; clrscr(); printf("Enter the first number:"); scanf("%d",&a); printf("Enter the second number:"); scanf("%d",&b); printf("Enter the operator:"); scanf("%s",&opr); switch(opr) { case'+': result=a+b; break; case'-': result=a-b; break;  case'*': result=a*b; break;  case'/': result=a/b; break;  case'%': result=a%b; break; default: printf("You are entered a invalid operator"); break; } printf("The result of %d %c %d is= %f",a,opr,b,result); getch(); } ...
Continue reading →

TO CHECK GIVEN NUMBER IS PALINDROME OR NOT

0 comments
#include<stdio.h> #include<conio.h> void main() { int num,sum=0,r,temp; clrscr(); printf("Enter the number:"); scanf("%d",&num); temp=num; while(num) { r=num%10; num=num/10; sum=sum*10+r; } if(temp==sum) printf("The given number is palindrome"); elseprintf("The given number not palindrome"); getch(); } ...
Continue reading →

MEAN AND STANDARD DEVIATION

0 comments
#include<stdio.h>  #include<conio.h> #include<math.h>  void main() { int n,a[25],i; float sum=0,sos=0,q,m,sd; clrscr(); printf("Enter the total number of elements:"); scanf("%d",&n); printf("Enter the elements"); for(i=1;i<=n;i++) { scanf("%d",&a[i]); sum=sum+a[i]; sos=sos+a[i]*a[i]; } m=sum/n; q=sos/n; sd=sqrt(q-m*m); printf("The mean of given numbers is=%f",m); printf("Standard deviation is =%f",sd); getch(); } Algorithm: 1.Start.2.Read n.3.assign i=1,sum=0,sos=04.If i<=n goto step5 else goto step9.5.Read a[i]6.Compute sum=sum+a[i]7.Compute sos=sos+a[i]*a[i]8.Assign ...
Continue reading →

TO FIND FIBONACCI SERIES USING C PROGRAM

0 comments
#include<stdio.h> int main() { int n,r,ncr; printf("Enter any two numbers-->"); scanf("%d",&n,&r); ncr=fact(n)/(fact(r)*fact(n-r)); printf("The NCR factor of %d and %d is %d",n,r,ncr); return 0; } int fact (int n) { int i=1; while(n!=0) { i=i*n; n--; } return i ...
Continue reading →

BINARY TO DECIMAL CONVERSION

0 comments
#include<stdio.h> #include<stdio.h>   #include<stdio.h> void main() { int i=0,num,decimal=0; long n; printf("Enter the binary number:"); scanf("%d",&n); while(n>0) {  num=n%10; decimal=decimal+num*pow(2,i); n=n/10; i=i+1; } printf("The decimal number is %d",decimal); getch(); } Algorithm: 1.Start.2.Read the binary number,n 3.Calculate ai2n-1+ai2n-2+ai2n-3+..................+ai24.Print the decimal equivalent of the binary.5.Stop. ...
Continue reading →

DECIMAL TO BINARY CONVERSION

0 comments
#include<stdio.h> #include<conio.h> #include<math.h>  void main() { int bin[10],i,j,N; printf("Enter the decimal number:"); scanf("%d",&N); i=0; while(N>0) { bin[i]=N%2; N=N/2; i=i+1; } printf("The binary number is:"); for(j=i-1;j>=0;j--) { printf("%d",bin[j]); } getch(); } Algorithm: 1.Start.2.Read the decimal number.3.Calculate the binary number using double-dabble method.4.Print the binary equivalent of the decimal.5.Stop. ...
Continue reading →