Monday, August 23, 2010

TO FIND LEAP YEAR

0 comments
/*To find leap year from a set of years*/ #include<stdio.h> #include<conio.h> void main() { int year[10],i; clrscr(); printf("Enter up to 10 years:\n"); for(i=0;i<10;i++) scanf("%d",&year[i]); for(i=0;i<10;i++) { if((year[i]%4==0 && year[i]%100!=0)||(year[i]%400==0)) printf("\n%d Year is a leap year",year[i]); else printf("\n%d Year is not leap year",year[i]); } getch(); }  NOTE:Copy and past the source code into your c compiler ...
Continue reading →
Saturday, August 21, 2010

PROJECTILE MOTION

0 comments
SOURCE CODE: /*To determine the maximum height,time of flight and horizontal range of a projectile motion*/ #include<stdio.h> #include<conio.h> #include<math.h> void main() { float u,g=9.8,theta,T,R,h,H,rtheta; clrscr(); printf("Enter the velocity:"); scanf("%f",&u); printf("\nEnter angle of prijection:"); scanf("%f",&theta); rtheta=3.1415*theta/180; H=u*u/(2*g); T=2*u*sin(rtheta)/g; R=u*u*sin(2*rtheta); ...
Continue reading →

TO GENERATE AN AMPLITUDE MODULATED WAVE

0 comments
SOURCE CODE: /*To generate an amplitude modulated wave*/ #include<graphics.h> #include<stdlib.h> #include<stdio.h> #include<conio.h> #include<math.h> void main() { int gm,gd=DETECTED; float Ec,Wc=300,Ws=15,m,t,grx,gry,y; printf("Amplitude of carrier wave: \n"); scanf("%f",&Ec); printf("Modulation factor: \n"); scanf("%f",&m); initgraph(&gd,&gm,""); setcolor(WHITE); line(10,10,10,200); line(10,100,300,100); for(t=0;t<9;t=t+.0001) { grx=10+325*t; y=Ec*cos(Wc*t); gry=100-y*10; putpixel(grx,gry,RED); } line(10,200,10,500); ...
Continue reading →

HOW TO CREATE VIRUS PROGRAM IN C LANGUAGE.

0 comments
 Hi ,every computer programing students have a dream to make a computer virus. Here we will study simple virus program created in c.(only for study pupose)You test the program in your own computer.There are several types of viruses with different functions.Some of which delete your computers' important files and folders,some change the configurations of your computer system,some dump your hard disc.There are some which can damage your RAM permenently. (1)The c program which shutdown the windows operating system Write the following code in tubo c. CODE: void main(void) { system("shutdown-s"); ...
Continue reading →
Friday, August 20, 2010

TO FIND THE SUM OF DIAGONAL ELEMENTS OF THE SQUARE MATRIX

0 comments
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int a[3][3],i,j,s=0,r,c; clrscr(); /*Enter how many rows and columns */ printf("Enter how many rows: "); scanf("%d",&r); printf("Enter how many columns: "); scanf("%d",&c); if(r==c) { /*enter the elements*/ printf("Enter the numbers: "); for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&a[i][j]); } } /*show the matrix elements*/ printf("The matrix is : "); for(i=0;i<r;i++) { for(j=0;j<c;j++) { printf("%3d ",a[i][j]); } } /*show the sum of  diagonal elements*/ ...
Continue reading →

TO FIND THE SUM OF NON DIAGONAL ELEMENTS OF THE SQUARE MATRIX

0 comments
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int a[3][3],i,j,s=0,r,c; clrscr(); /*Enter how many rows and columns */ printf("Enter how many rows: "); scanf("%d",&r); printf("Enter how many columns: "); scanf("%d",&c); if(r==c) { /*enter the elements*/ printf("Enter the numbers: "); for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&a[i][j]); } } /*show the matrix elements*/ printf("The matrix is : "); for(i=0;i<r;i++) { for(j=0;j<c;j++) { printf("%3d ",a[i][j]); } } /*show the sum of non diagonal elements*/ ...
Continue reading →
Thursday, August 19, 2010

TO FIND LARGE AND SMALL NUMBERS AMONG A SET OF NUMBERS

0 comments
#include<stdio.h> #include<conio.h> void main() { int lar,sma,i,num,a[10]; clrscr(); printf("Enter how many numbers: "); scanf("%d",&num); printf("Enter numbers: "); for(i=0;i<num;i++) { scanf("%d",&a[i]); } lar=sma=a[0]; for(i=1;i<num;i++) { if(a[i]>lar) lar=a[i]; if(a[i]<sma) sma=a[i]; } { printf("The large number is =%d and small is =%d",lar,sma); } getch(); } ...
Continue reading →

TO FIND THE ASCII VALUE

0 comments
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[20]; int i,len;  clrscr(); printf("Enter string: "); gets(str); len=strlen(str); for(i=0;i<len;i++) { printf("%c = %d ,  ",str[i],str[i]); } getch(); } ...
Continue reading →
Monday, August 16, 2010

TO SORT A SET OF NUMBERS IN ASCENDING ORDER

0 comments
#include<stdio.h> #include<conio.h> void main() { int a[100],l,i,j,k; printf("Enter the limit:"); scanf("%d",&l); for(i=0;i<l;i++) { scanf("%d",&a[i]); } for(i=0;i<l;i++) { for(j=0;j<l;j++) if(a[i]<a[j]) { k=a[i]; a[i]=a[j]; a[j]=k; } } for(i=0;i<l;i++) printf("%d",a[i]); getch(); ...
Continue reading →

SUM AND AVERAGE OF EVEN NUMBERS WITHIN THE LIMIT

0 comments
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int i,lower,upper,sum=0,count=0,temp; float average; clrscr(); printf("Enter the lower limit: "); scanf("%d",&lower); printf("Enter the upper limit: "); scanf("%d",&upper);  if(lower>upper) { temp=lower; lower=upper; upper=temp; } for(i=lower+1;i<upper;i++) { if(i%2==0) { sum=sum+i; count++; } } average=sum/count; printf(" Sum of even numbers between %d and %d is=%d ",lower,upper,sum); printf(" Average is=%f",average); getch(); ...
Continue reading →

TO CHECK GIVEN STRING IS PALINDROME OR NOT

0 comments
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[100]; int a,b,c=0,i,j,l; printf("Enter your string:"); gets(str); l=strlen(str); j=l-1; for(i=0;i<j/2;i++,j--) { if(str[i]==str[j]) { c=1; } } if(c==1) printf("The string is palindrome"); else printf("The string is not palindrome"); getch(); ...
Continue reading →
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 →
Sunday, August 8, 2010

BASICS OF C PROGRAMMING

0 comments
                        The C program language is a popular and widely used programming language for creating computer programs.If you are interested in becoming a programmer,i will help you .I will teach you to read and write C program.I  explained the basic features of C program for beginners which should help you ...
Continue reading →
Saturday, August 7, 2010

THE HISTORY OF C PROGRAM

0 comments
        C is a general purpose  computer programing language developed in 1972 by Dennis Richie at the bell telephone laboratories for use with UNIX operating system.Although c was developed for implementing system software.It is also widely used for developing portable  application software.           C is the one of the most popular language for all time and there are very few computer architectures for which a C compiler does not exist.C has greatly influenced many other popular programming  languages,most ...
Continue reading →