## PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING FOR LOOP

/* PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING FOR LOOP */ #include<stdio.h> #include<conio.h> void main() { int n,i,fact=1; clrscr(); printf(“\n\nENTER THE VALUE OF N :”); scanf(“%d”,&n); for(i=1;i<=n;i++) { fact=fact*i; } printf(“\n\nTHE FACTORIAL OF N IS : %d”,fact); getch(); }

## PROGRAM TO PRINT THE PATTERN (Square *)

/* PROGRAM TO PRINT THE PATTERN * * * * * * * * * * * * * * * * * * * * */ #include<stdio.h> #include<conio.h> void main() { int i,j,n,k; clrscr(); printf(“\n\nENTER HOW MANY ROWS : “); scanf(“%d”,&n); for(i=1;i<=n;i++) { if(i==1) { for(j=1;j<=n+2;j++) { printf(““); } } else if(i==n) { printf(“\n”); […]

## PROGRAM TO PRINT HELLO HELLO HELLO BYE BYE BYE

/* PROGRAM TO PRINT HELLO HELLO HELLO BYE BYE BYE */ #include<stdio.h> #include<conio.h> void main() { int i,j,n; clrscr(); printf(“ENTER HOW MANY TIMES YOU WANTS TO PRINT THIS PATTERN :”); scanf(“%d”,&n); printf(“\n\n”); for(i=1;i<=n;i++) { printf(“HELLO “); } printf(“\n”); for(j=1;j<=n;j++) { printf(“BYE “); } getch(); }

## PROGRAM TO PRINT THE PATTERN * * * * * * * * * * * * * *

/* PROGRAM TO PRINT THE PATTERN * * * * * * * * * * * * * * */ #include<stdio.h> #include<conio.h> void main() { int i,n; clrscr(); printf(“\n\nENTER HOW MANY STARS YOU WANT TO PRINT :”); scanf(“%d”,&n); printf(“\n\n”); for(i=1;i<=n;i++) { printf(” *”); } getch(); }

## PROGRAM TO PRINT THE ‘n’ TABLES

/* PROGRAM TO PRINT THE ‘n’ TABLES */ #include<stdio.h> #include<conio.h> void main() { int i,n,t,j; clrscr(); printf(“\n\nENTER THE VALUE OF N :”); scanf(“%d”,&n); for(i=1;i<=n;i++) { printf(“\n\n THE %d’s TABLE IS\n\n”,i); for(j=1;j<=10;j++) { t=i*j; printf(“\n %d * %d = %d\n”,i,j,t); } getch(); } getch(); }

## PROGRAM TO FIND THE AVERAGE OF ‘n’ NUMBERS USING FOR LOOP

/* PROGRAM TO FIND THE AVERAGE OF ‘n’ NUMBERS USING FOR LOOP */ #include<stdio.h> #include<conio.h> void main() { int n,i; float avg,sum=0.0; clrscr(); printf(“\n\nENTER THE VALUE OF N : “); scanf(“%d”,&n); for(i=1;i<=n;i++) { sum+=i; } avg=sum/n; printf(“\n\nTHE AVERAGE OF FIRST N NUMBERS IS : %f”,avg); getch(); }

## PROGRAM TO DETERMINE THE SIZE OF INT, CHAR, FLOAT, DOUBLE TYPE OF DATA TYPE IN COMPUTER MEMORY

/* PROGRAM TO DETERMINE THE SIZE OF INT,CHAR,FLOAT,DOUBLE TYPE OF DATA TYPE IN COMPUTER MEMORY */ #include<stdio.h> #include<conio.h> void main() { clrscr(); printf(“\n\nTHE SIZE OF INT IS : %d”,sizeof(int)); printf(“\n\nTHE SIZE OF FLOAT IS : %d”,sizeof(float)); printf(“\n\nTHE SIZE OF CHAR IS : %d”,sizeof(char)); printf(“\n\nTHE SIZE OF DOUBLE IS: %d”,sizeof(double)); getch(); }

## PROGRAM TO INTERCHANGE THE VALUE OF A AND B

/* PROGRAM TO INTERCHANGE THE VALUE OF A AND B */ #include<stdio.h> #include<conio.h> void main() { int a,b,temp; clrscr(); printf(“\n\n ENTER THE VALUE OF A :”); scanf(“%d”,&a); printf(“\n\n ENTER THE VALUE OF B :”); scanf(“%d”,&b); temp=a; a=b; b=temp; printf(“\n\nAFTER INTERCHANGING”); printf(“\n\nA : %d”,a); printf(“\n\nB : %d”,b); getch(); }

## PROGRAM TO ENTER THE REVERSE NUMBER OF 12345

/* PROGRAM TO ENTER THE REVERSE NUMBER OF 12345 */ #include<stdio.h> #include<conio.h> void main() { int n=12345,r; clrscr(); printf(” \n\nTHE REVERSE OF 12345 IS : “); while(n>0) { r=n%10; printf(“%d”,r); n=n/10; } getch(); }

## PROGRAM TO PRINT THE PATTERN ***** +++++

/* PROGRAM TO PRINT THE PATTERN ***** +++++ */ #include<stdio.h> #include<conio.h> void pattern(int n); void main() { int n; clrscr(); printf(“\n\nENTER THE VALUE OF N :”); scanf(“%d”,&n); pattern(n); getch(); } void pattern(int n) { int i,j; printf(“\n\n\t\t”); for(i=1;i<=n;i++) { printf(“*”); } printf(“\n\n\t\t”); for(j=1;j<=n;j++) { printf(“+”); } }

## PROGRAM TO FIND PRIME NUMBERS USING FUNCTION

/* PROGRAM TO FIND PRIME NUMBERS USING FUNCTION */ #include<stdio.h> #include<conio.h> void prime(int n); void main() { int n; textcolor(69); clrscr(); printf(“\n ENTER HOW MANY PRIME NUMBERS YOU WANTS TO FIND :”); scanf(“%d”,&n); prime(n); getch(); } void prime(int n) { int x,i,j,count=0; for(i=2;i<=10000;i++) { x=0; for(j=2;j<=i/2;j++) { if(i%j==0) { x=1; break; } } if(x==0) { […]

## PROGRAM TO DEMONSTRATE THE DIFFERENCE BETWEEN AUTOMATIC AND STATIC VARIABLES

/* PROGRAM TO DEMONSTRATE THE DIFFERENCE BETWEEN AUTOMATIC AND STATIC VARIABLES */ #include<stdio.h> #include<conio.h> void func1(); void func2(); void main() { textcolor(90); clrscr(); printf(“\n\nFUNCTION CALLING ONE SHOWS CHANGES OF AUTO VARIABLE\n\n”); printf(“\n\nAFTER FIRST CALL OF VALUE OF I IN AUTO VARIABLE IS \n”); func1(); printf(“\n\nAFTER SECOND CALL OF VALUE OF I IN AUTO VARIABLE IS […]

## PROGRAM TO FIND THE FIBONACCI SERIES USING FUNCTION

/* PROGRAM TO FIND THE FIBONACCI SERIES USING FUNCTION */ #include<stdio.h> #include<conio.h> void fib(int n); void main() { int n; clrscr(); printf(“ENTER THE VALUE OF N: “); scanf(“%d”,&n); fib(n); getch(); } void fib(int n) { int a=0,b=1,i,temp,f; printf(“THE FIBONACCI SERIES IS \n\n”); printf(“%d %d “,a,b); for(i=1;i<=n-2;i++) { f=a+b; a=b; b=f; printf(” %d “,f); } }

## PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING FUNCTION

/* PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING FUNCTION */ #include<stdio.h> #include<conio.h> int fact(int n); void main() { int n; clrscr(); printf(“\nENTER THE NUMBER :”); scanf(“%d”,&n); fact(n); printf(“\n FACTORIAL OF N IS : %d”,fact(n)); getch(); } int fact(int num) { int i; int f=1; if(num>1) { for(i=1;i<=num;i++) f=f*i; } return(f); }

## PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING RECURSION

/* PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING RECURSION */ #include<stdio.h> #include<conio.h> int fact(int n); void main() { int n,fac; clrscr(); printf(“ENTER THE NUMBER : “); scanf(“%d”,&n); fac=fact(n); printf(“THE FACTORIAL OF A NUMBER IS : %d”,fac); getch(); } int fact(int n) { int f; if(n==1) { return 1; } else { return (n*fact(n-1)); […]

## PROGRAM TO SHOW CONCEPT OF SWAPPING USING FUNCTION

/* PROGRAM TO SHOW CONCEPT OF SWAPPING USING FUNCTION */ #include<stdio.h> #include<conio.h> void swap(int a,int b); void main() { int a,b; clrscr(); printf(“ENTER THE VALUE OF A :”); scanf(“%d”,&a); printf(“ENTER THE VALUE OF B :”); scanf(“%d”,&b); swap(a,b); getch(); } void swap(int x,int y) { int temp; temp=x; x=y; y=temp; printf(“\nAFTER SWAPPING\n”); printf(“\nA :%d “,x); printf(“\nB […]

## PROGRAM TO COMPUTE SIMPLE INTEREST WITH ARGUMENT AND RETURN VALUE

/* PROGRAM TO COMPUTE SIMPLE INTEREST WITH ARGUMENT AND RETURN VALUE */ #include<stdio.h> #include<conio.h> float simple(int p,float r,int t); void main() { int p,t; float r,si; clrscr(); printf(“ENTER THE VALUE OF PRINCIPLE :”); scanf(“%d”,&p); printf(“ENTER THE VALUE OF RATE :”); scanf(“%f”,&r); printf(“ENTER THE VALUE OF TIME :”); scanf(“%d”,&t); si=simple(p,r,t); printf(“THE SIMPLE INTEREST IS :%f”,si); getch(); […]

## PROGRAM TO COMPUTE SIMPLE INTEREST WITH ARGUMENTS BUT RETURN NOTHING

/* PROGRAM TO COMPUTE SIMPLE INTEREST WITH ARGUMENTS BUT RETURN NOTHING */ #include<stdio.h> #include<conio.h> void simple(int p,float r,int t); void main() { int p,t; float r; clrscr(); printf(“ENTER THE VALUE OF PRINCIPLE :”); scanf(“%d”,&p); printf(“ENTER THE VALUE OF RATE :”); scanf(“%f”,&r); printf(“ENTER THE VALUE OF TIME :”); scanf(“%d”,&t); simple(p,r,t); getch(); } void simple(int pr,float rt,int […]

## PROGRAM TO FIND THE SIMPLE INTEREST WITH NO ARGUMENT AND NO RETURN VALUE

/* PROGRAM TO FIND THE SIMPLE INTEREST WITH NO ARGUMENT AND NO RETURN VALUE */ #include<stdio.h> #include<conio.h> void simple(); void main() { clrscr(); simple(); getch(); } void simple() { long int p,t; float r,si; printf(“\n ENTER THE VALUE OF PRINCIPLE : “); scanf(“%ld”,&p); printf(“\n ENTER THE VALUE OF RATE : “); scanf(“%f”,&r); printf(“\n ENTER THE […]

## PROGRAM TO PRINT THE ENTERED NUMBER IS POSITIVE OR NEGATIVE

/* PROGRAM TO PRINT THE ENTERED NUMBER IS POSITIVE OR NEGATIVE */ #include<stdio.h> #include<conio.h> void check(int n); void main() { int n; clrscr(); printf(“\n\n ENTER THE NUMBER : “); scanf(“%d”,&n); check(n); getch(); } void check(int num) { if(num>0) printf(“\n\n THE NUMBER ENTERED IS POSITIVE”); else if(num<0) printf(“\n\n THE NUMBER ENTERED IS NEGATIVE”); else printf(“\n\n THE […]