| |

:. PDS (IT) .:

HI DIS IS U R FRND DURGESH SITE ONLY FOR JOKES AND PDS

Hi frnds dis Durgesh frm warangal. I'm student in RGUKT. Dis is My small C_Language Programs. If u hv interest den u can copy and execute...


************************************************************

FRNDSHIP_CAL

#include<"stdio.h">
#include<"string.h">

/* Program to check strings input and output using C */
/* hi dis is Durgesh second frndship cal so type ur and ur frnd name den check u r frndship percentage */

main()

{

int i=0,j=0,len_y=0,len_f=0,count=0;
char y_name[50];
char f_name[50];

printf("Enter your good name here:");
gets (y_name);

len_y=strlen(y_name);

printf("Enter your friend's name here:");
gets (f_name);

len_f=strlen(f_name);

if(len_y > len_f)
{
for(i=0; i= 0 && count < 30) printf("Your bond is too weak. It is only %d%%\n",count); else if(count> 29 && count <60) printf("Your friendship is having an average strength. It is only %d%%\n",count); else if(count> 59 && count <80) printf("Your friendship is strong. It is %d%%\n",count); else if(count> 79 && count <100) printf("Your friendship is too strong. No one can break your friendship. It is %d%%\n",count); else if(count> 100)
{
count=100;
printf("Your friendship is too strong. No one can break your friendship. It is %d%%\n",count);
}


}


************************************************************


LOVE_CAL




Hi frds this is about love_cal how much u r percentage den check it.....






#include<"stdio.h">
#include<"string.h">
#include<"math.h">

/* Program to check strings input and output using C */
/* This is Durgesh first love_cal program type the names and check u r love */

main()

{

int i=0,j=0,len_y=0,len_f=0,count=0,large;
char y_name[50];
char f_name[50];

printf("Enter your name here:");
gets (y_name);

len_y=strlen(y_name);

printf("Enter your Lover's name here:");
gets (f_name);

len_f=strlen(f_name);

if(len_y > len_f)
{
large=len_y;
for(i=0; i= 0 && count < 30) printf("Your bond is too weak. It is only %d%%\n",count); else if(count> 29 && count <60) printf("Your Love is having an average strength. It is only %d%%\n",count); else if(count> 59 && count <80) printf("Your Love is strong. It is %d%%\n",count); else if(count> 79 && count <100) printf("Your Love is too strong. No one can break your friendship. It is %d%%\n",count); else if(count> 100)
{
count=100;
printf("Your Love is too strong. No one can break your friendship. It is %d%%\n",count);
}


}



****************************************************************


LCM & GCD




Hi frnds dis is about LCM and GCD program. check it dent get the values.....





/* This program prints LCM and GCD of given two numbers */
#include<"stdio.h">


main()

{

int a,b,c=1,i;

printf(“Enter two numbers:”);

scanf(“%d%d”,&a,&b);

i=2;

while(i<=a || i<=b) { if(a%i==0 && b%i==0) { a=a/i; b=b/i; c=i*c; } else { i++; } } printf("GCD=%d\n",c); printf("LCM=%d\n",a*b*c); } *********************************************************

REVERSE NUMBER:



.........This Program prints reverse numbers.....

#include<"stdio.h">

main()
{
int a,b,c=1,d,f=0;

scanf(“%d”,&b);

while(b>=1)
{
d=b%10;

printf(“%d\t”,d);

f=f+d;

b=(b-d)/10;
}


printf(“\n\n”);

printf(“%d\n”,f);
}

*********************************************************



PRIME NO: UP 2 n :



this program about the prime numbers print upto nth number….




/*This following program print prime numbers up to nth range*/
#include<"stdio.h">


main()
{
int n,i=1,j,c;

printf(“Enter Number Of Terms:”);

scanf(“%d”,&n);

while(i<=n) { c=0; for(j=1;j<=i;j++) { if(i%j==0) c++; } if(c==2) printf("%d\n",i); i++; } } //"Prime Numbers Are Follwing" ***************************************************************

COUNTING:





#include<"stdio.h">

/* count digits, white space, others */

main()

{

int c, i, nwhite, nother;

int ndigit[10];

nwhite = nother = 0;

for (i = 0; i = ’0′ && c <= '9') ++ndigit[c-'0']; else if (c == ' ' || c == '\n' || c == '\t') ++nwhite; else ++nother; printf("digits ="); for (i = 0; i < 10; ++i) printf(" %d", ndigit[i]); printf(", white space = %d, other = %d\n",nwhite, nother); } **********************************************************

PRIME UP 2 RANGE :



/*This program ABOUT prime numbers up to nth range*/

#include<"stdio.h">

main()

{

int i, j, count, n;

printf(“Enter the number:- “);


scanf(“%d”, &n);

printf(“The prime numbers are:- “);

for(i=1;i

TRIANGEL :



dis is about to pritn triangle......





#include<"stdio.h">

main()

{

int a,d=1;

for(a=1;a=a)

{
printf(“%s”,” “);
b–;

}

int c=1;

while(c<=a) { printf("%s ","*"); c++; d++; } printf("\n"); } } *****************************************************

REVERSE :


dis is about print the reverse.........


#include<"stdio.h">

main()

{
int a;

printf(“Enter your num:”);

scanf(“%d”,&a);

while (a!=0)
{
int b;

b = a%10;

printf(“%d”,b);

a = a/10;

}
printf(“\n”);
}


************************************************************


SUM DIGIT :


dis is about the Sum of digits of Given number:

#include<"stdio.h">


main()

{
int a,sum=0;

printf(“Enter your num:”);

scanf(“%d”,&a);

while (a!=0)
{
int b;

b = a%10;

sum = sum + b;

a = a/10;

}
printf(“Sum of the Digits is: %d\n”,sum);
}


******************************************************************


FIND PERMUTATIONS :




#include<"stdio.h">

// To find the combinations and premutations for given n,r values

long fact(n)

{
int b=1,x=1;

while(b<=n) { x=b*x; b++; } return x; } float comb(n,r) { float x; x = fact(n)/((fact(r))*(fact(n-r))); printf("\nThe possible combinations to select r objects from n objects is %f\n\n",x); } float perm(n,r) { float x; x = fact(n)/(fact(n-r)); printf("\nThe possible permutations to select r objects from n objects is %f\n\n",x); } int main() { int n,r; printf("Enter the total number of objects n = "); scanf("%d",&n); printf("Enter the number of objects to be selected r = "); scanf("%d",&r); comb(n,r); perm(n,r); return 0; } *******************************************************

EVEN & ODD :




#include<"stdio.h">

main()

{


int a;

printf("Value of number a = ");

scanf("%d",&a);

if(a%2==0)

printf("The given input %d is even number\n",a);

else
printf("The given input %d is odd number\n",a);


}








****************************************************




MULTIPLICATION TABEL :




#include<"stdio.h">

void table(int x) //defining function table(intx)
{
int m;

for(m=1; m<=x; m++) { printf("\n\n"); int i=1; while(i<=10) { printf("%d*%d=%d",m,i,m*i); i++; printf("\n"); } } } main() //main function begining { int r; printf("Enter your number r here"); scanf("%d",&r); table(r); //function calling } ********************************************************

NATURAL SUM :



#include<"stdio.h">


int natural_sum(n)

{

int x=0,y=0;

while(x<=n) { y=y+x; x++; } return y; } main() { int n; printf("Enter your number here "); scanf("%d",&n); printf("Sum upto %d natural numbers is %d\n",n,natural_sum(n)); } OR #include<"stdio.h">


int natural_sum(n)

{

int sum;

sum = (n*(n+1))/2;

return sum;

}


main()
{

int n;

printf("Enter your number here ");

scanf("%d",&n);

printf("Sum upto %d natural numbers is %d\n",n,natural_sum(n));

}




*********************************************************


FIND EVEN & ODD NO :




#include<"stdio.h">

main()

{


int m,n,x;


printf("Enter the value of n = ");

scanf("%d",&n);

printf("Even No: Odd No:\n");

printf("......... ........\n");

for(m=1; m<=n; m++) { if(m%2==0) { x=m*m; printf("%d\n",x); } else printf(" %d\n",m); } } ***********************************************

PRINT MALTIPUL TIMES :




#include<"stdio.h">


main ()

{

int x,y,z;

printf("Enter any symbol to get the multiple times = ");

char c = getchar();

printf("Enter the value of x =");

scanf("%d",&x);


for (y = 1 ; y<= x ; y++) { for (z = 1; z<=y ; z++) { printf("%c",c); } printf("\n"); } } **************************************************

POWER AND BASE :



#include<"stdio.h">

float power(long x,long y)
{

long i=1;

float m=1;

if(y>0)

{
while(i<=y) { m=m*x; i++; } } else if(y<0) { y=-1*y; while(i<=y) { m=m*x; i++; } m=1/m; } else if(y==0) m=1; return m; } main() { long x,y; printf("Enter the values of base and power \n"); scanf("%ld %ld",&x,&y); printf("%f\n",power(x,y)); } *********************************************************

PRIME NO:




#include<"stdio.h">

main( )


{
int num, i ;

printf ( "Enter a number " ) ;

scanf ( "%d", &num ) ;


i=2;

while ( i <= num - 1 ) { if ( num % i == 0 ) { printf ( "Not a prime number\n" ) ; break ; } i++ ; } if ( i == num ) printf ( "Prime number\n" ) ; } ******************************************************

QUADRADIC EQUATION :



#include<"stdio.h">


#include<"math.h">

# define AMMA 10

main()

{

int a,b,c,g=0,h=0,i=0;
printf("a*x^2+b*x+c");
printf("Enter the a ,b,c values:\n");
scanf("%d %d %d",&a,&b,&c);



for (i = AMMA ; i >= (-1)*AMMA ; i--)

{
g = a* pow (i,2) + b* pow (i,1) + c;

h = g;

if (h == 0)
{
printf("%d",i);

printf("\n");

}
else

continue;


}


}





*********************************************


SQUARE & CUBE :



#include<"stdio.h">

void output (int x);

main()

{

int x;

printf("Entet the one number:\n");

scanf("%d",&x);


output(x);

}
void output (int x)
{
int i;

printf("Int\tsquare\tcube\n");

for (i = 1; i<= x ; i++) printf("%d\t %d\t %d\n",i,i*i,i*i*i); } ***************************************************************

FIND FIBONIC EQN :





#include<"stdio.h">

void main()

{

int num1=0, num2=1,no,counter,fab;

clrscr();



printf("<===========PROGRAM TO FIND THE FIBONACCI SERIES UP TO N NO. IN SERIES=========>");

printf("\n\n\n\t\tENTER LENGTH OF SERIES (N) : ");

scanf("%d",&no);



printf("\n\n\t\t\t<----FIBONACCI SERIES---->");

printf("\n\n\t\t%d %d",num1,num2);



//LOOP WILL RUN FOR 2 TIME LESS IN SERIES AS THESE WAS PRINTED IN ADVANCE

for(counter = 1; counter <= no-2; counter++) { fab=num1 + num2; printf(" %d",fab); num1=num2; num2=fab; } getch(); } ********************************************************************

FACTORIAL :



#include<"stdio.h">




unsigned int recr_factorial(int n);

unsigned int iter_factorial(int n);



void main()

{

int n,i;

long fact;

clrscr();

printf("Enter the number: ");

scanf("%d",&n);



if(n==0)

printf("Factorial of 0 is 1\n");

else

{

printf("Factorial of %d Using Recursive Function is %d\n",n,recr_factorial(n));

printf("Factorial of %d Using Non-Recursive Function is %d\n",n,iter_factorial(n));

}

getchar();

}



/* Recursive Function*/

unsigned int recr_factorial(int n) {

return n>=1 ? n * recr_factorial(n-1) : 1;

}



/* Non-Recursive Function*/

unsigned int iter_factorial(int n) {

int accu = 1;

int i;

for(i = 1; i <= n; i++) { accu *= i; } return accu; } ***********************************************************

GCD :




#include<"stdio.h">


#include<"math.h">



unsigned int GcdRecursive(unsigned m, unsigned n);

unsigned int GcdNonRecursive(unsigned p,unsigned q);



int main(void)

{

int a,b,iGcd;

clrscr();



printf("Enter the two numbers whose GCD is to be found: ");

scanf("%d%d",&a,&b);



printf("GCD of %d and %d Using Recursive Function is %d\n",a,b,GcdRecursive(a,b));

printf("GCD of %d and %d Using Non-Recursive Function is %d\n",a,b,GcdNonRecursive(a,b));



getchar();

}



/* Recursive Function*/

unsigned int GcdRecursive(unsigned m, unsigned n)

{

if(n>m)

return GcdRecursive(n,m);

if(n==0)

return m;

else

return GcdRecursive(n,m%n);

}



/* Non-Recursive Function*/

unsigned int GcdNonRecursive(unsigned p,unsigned q)

{

unsigned remainder;

remainder = p-(p/q*q);



if(remainder==0)

return q;

else

GcdRecursive(q,remainder);

}





****************************************************************


PALINDROME :



#include<"stdio.h">

#include<"string.h">



enum Boolean{false,true};

enum Boolean IsPalindrome(char string[])

{

int left,right,len=strlen(string);

enum Boolean matched=true;

if(len==0)

return 0;

left=0;

right=len-1;



/* Compare the first and last letter,second & second last & so on */

while(left

PASCAL TRIANGLE:




#include<"stdio.h">




void main()

{

int bin,p,q,r,x;

clrscr();

bin=1;

q=0;



printf("Rows you want to input:");

scanf("%d",&r);



printf("\nPascal's Triangle:\n");



while(q0;--p)

printf(" ");

for(x=0;x<=q;++x) { if((x==0)||(q==0)) bin=1; else bin=(bin*(q-x+1))/x; printf("%6d",bin); } printf("\n"); ++q; } getchar(); } ***************************************************************

PYRAMID :



#include<"stdio.h">




void main()

{

int num,i,y,x=35;

clrscr();

printf("\nEnter the number to generate the pyramid:\n");

scanf("%d",&num);



for(y=0;y<=num;y++) { /*(x-coordinate,y-coordinate)*/ gotoxy(x,y+1); /*for displaying digits towards the left and right of zero*/ for(i=0-y;i<=y;i++) printf("%3d",abs(i)); x=x-3; } getchar(); } ***************************************************************

FIND THE ROOTS:



#include<"stdio.h">



#include<"math.h">



void main()

{

float a,b,c,root1,root2;

clrscr();

printf("\n Enter values of a,b,c for finding roots of a quadratic eq:\n");

scanf("%f%f%f",&a,&b,&c);



/*checking condition*/

if(b*b>4*a*c)

{

root1=-b+sqrt(b*b-4*a*c)/2*a;

root2=-b-sqrt(b*b-4*a*c)/2*a;

printf("\n*****ROOTS ARE*****\n");

printf("\n root1=%f\n root2=%f",root1,root2);

}

else

printf("\n Imaginary Roots.");

getchar();

}




**************************************************************



SEARCH STRING :




#include<"stdio.h">

#include<"string.h">




void main()

{

char s[30], t[20];

char *found;

clrscr();



/* Entering the main string */

puts("Enter the first string: ");

gets(s);



/* Entering the string whose position or index to be displayed */

puts("Enter the string to be searched: ");

gets(t);



/*Searching string t in string s */

found=strstr(s,t);

if(found)

printf("Second String is found in the First String at %d position.\n",found-s);

else

printf("-1");

getchar();

}





******************************************************************



SUM OF DIGITS :



#include<"stdio.h">




void main()

{

int num, k=1, sum=0;

clrscr();

printf("Enter the number whose digits are to be added:");

scanf("%d",&num);

while(num!=0)

{

k=num%10;

sum=sum+k;

k=num/10;

num=k;

}

printf("Sum of the digits:%d",sum);

getchar();

}

THANKS FOR VISTINTG