// User Defined Inner File Without Argument Function
#include<stdio.h>
#include<conio.h>
int getno(); // Prototype Declaration
int addno();
int showno();
int a,b,c; // Global Variable
void main()
{
clrscr();
getno();
addno();
showno();
getch();
}
/* Inner file function declarations*/
int getno()
{
printf("Enter Two Numbers ");
scanf("%d%d",&a,&b);
return 0;
}
int addno()
{
c=a+b;
return 0;
}
int showno()
{
printf("%d + %d = %d\n",a,b,c);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File Without Argument Function( Without Return)
#include<stdio.h>
#include<conio.h>
void getno();
void addno();
void showno();
int a,b,c; // Global Variable
void main()
{
clrscr();
getno();
addno();
showno();
getch();
}
/* Inner file function declarations*/
void getno()
{
printf("Enter Two Numbers ");
scanf("%d%d",&a,&b);
}
void addno()
{
c=a+b;
}
void showno()
{
printf("%d + %d = %d\n",a,b,c);
printf("\nPress Any Key to Exit............");
}
// User Defined Inner File With Argument Function
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
int showno(int);
void main()
{
int a,b,c;
clrscr();
a=getno();
b=getno();
c=addno(a,b);
showno(c);
getch();
}
/* Inner file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int z;
z=m+n;
return z;
}
int showno(int k)
{
printf("Addition of the Numbers = %d\n",k);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File With Argument Function Using Same Variables
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
int showno(int);
void main()
{
int a,b,c;
clrscr();
a=getno();
b=getno();
c=addno(a,b);
showno(c);
getch();
}
/* Inner file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int x;
x=m+n;
return x;
}
int showno(int x)
{
printf("Addition of the Numbers = %d\n",x);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File With Argument Function Using no Variables in main
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
void main()
{
clrscr();
addno(getno(),getno());
getch();
}
/* Inner file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int x;
x=m+n;
printf("%d + %d = %d\n",n,m,x);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File With Argument Function Calling Another Function
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
void showno();
void main()
{
clrscr();
showno();
getch();
}
/* Inner file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int x;
x=m+n;
printf("%d + %d = %d\n",m,n,x);
printf("\nPress Any Key to Exit............");
return 0;
}
void showno()
{
int a,b;
a=getno();
b=getno();
addno(a,b);
}
// Inner File Function Using If To Accept Or Reject Password
#include<stdio.h>
int password(int);
int getno();
int no();
int addno(int, int);
int showno();
void main()
{
int x=0;
clrscr();
x=getno();
password(x);
getch();
}
int password(int m)
{
int a,b;
if (m==12345)
{
printf("\nPassword Accepted .....\n");
a=no();
b=no();
addno(a,b);
}
else
{
printf("\nAccess Denied.....\nBetter Luck For Next Time.");
printf("\nPress Any Key to Exit............");
}
return 0;
}
int addno(int a,int b)
{
int c;
c=a+b;
showno(c);
return 0;
}
int showno(int c)
{
printf("Addition = %d\n",c);
printf("\nPress Any Key to Exit............");
return 0;
}
int getno()
{
int a;
printf("Enter Two Password= ");
scanf("%d",&a);
return a;
}
int no()
{
int a;
printf("Enter No ");
scanf("%d",&a);
return a;
}
// User Defined Inner File With Argument Function Calling Another Function to add, sub, //multi and div
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
int subno(int,int);
int mulno(int,int);
int divno(float,float);
void showno();
void main()
{
clrscr();
showno();
getch();
}
/* Inner file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
void showno()
{
int a,b;
a=getno();
b=getno();
addno(a,b);
subno(a,b);
mulno(a,b);
divno(a,b);
printf("\nPress Any Key to Exit............");
}
int addno(int m,int n)
{
int x;
x=m+n;
printf("\n%d + %d = %d\n",m,n,x);
return 0;
}
int subno(int m,int n)
{
int x;
x=m-n;
printf("\n%d - %d = %d\n",m,n,x);
return 0;
}
int mulno(int m,int n)
{
int x;
x=m*n;
printf("\n%d x %d = %d\n",m,n,x);
return 0;
}
int divno(float m,float n)
{
float x;
x=m/n;
printf("\n%.2f / %.2f = %f\n",m,n,x);
return 0;
}
//Write A Function Enter A Number In Decimal And Convert It To Binary Equivalent.
#include<stdio.h>
#include<conio.h>
long int convert(long int);
long int getno();
void main()
{
long int a;
clrscr();
a=getno();
convert(a);
getch();
}
long int convert(long int n)
{
long int s=1,a,b=0;
while(n!=0)
{
a=n%2;
b=b+a*s;
s=s*10;
n=n/2;
}
printf("Result=%ld",b);
return b;
}
long int getno()
{
long int x;
printf("Enter a no in decimal= ");
scanf("%ld",&x);
return x;
}
// Create A Function To Convert Temperature From Celsius To Fahrenheit.
#include<stdio.h>
#include<conio.h>
float gettmp();
void ctof(float);
void main()
{
int tmp;
clrscr();
tmp=gettmp();
ctof(tmp);
getch();
}
float gettmp()
{
float ft;
printf("Enter Celcius Temperature");
scanf("%f",&ft);
return ft;
}
void ctof(float t)
{
float f;
f=(9*t+160)/5;
printf("Fahrenheit Temperature =%.2f",f);
}
// Create A Function To Find All Odd And Even Number In A Specified Nos.
#include<stdio.h>
#include<conio.h>
int oddcount=0, evencount=0;
int getno();
void odd_even(int);
void main()
{
clrscr();
getno();
getch();
}
int getno()
{
int no,x,i;
printf("How many nos");
scanf("%d",&x);
for(i=0;i<=x;i++)
{
printf("\nEnter a no");
scanf("%d",&no);
odd_even(no);
}
no=0;
return 0;
}
void odd_even(int m)
{
if(m%2==0)
{
evencount++;
}
else
{
oddcount++;
}
printf("Odd Numbers = %d\nEven Numbers = %d",oddcount,evencount);
}
// Create A Function To Calculate The Simple Interest On Principle, Rate , Time.
#include<stdio.h>
#include<conio.h>
float si(float, float, int);
float amt(float, float);
void getnos();
void main()
{
clrscr();
getnos();
getch();
}
void getnos()
{
float p,r,m;
int t;
printf("Enter Principle");
scanf("%f",&p);
printf("Enter Rate");
scanf("%f",&r);
printf("Enter time in Year");
scanf("%d",&t);
m=si(p,r,t);
printf("Simple interest = %f",m);
printf("\nFinal Amount = %f",amt(p,m));
}
float si(float p, float r , int t)
{
float si;
si=p*r*t/100;
return si;
}
float amt(float m, float n)
{
float x;
x=m+n;
return x;
}
// Create a function to calculate the perfect triangle or not.
#include<stdio.h>
#include<conio.h>
void ptria(int,int,int);
int getnos();
void main()
{
clrscr();
ptria(getnos(),getnos(),getnos());
getch();
}
int getnos()
{
int a;
printf("Enter the triangle");
scanf("%d",&a);
return a;
}
void ptria(int l, int b , int h)
{
if((l+b+h)==180)
{
printf("Perfect Triangle");
}
else
{
printf("Not a Perfect Triangle");
}
}
// Create a function to calculate the table of a number.
#include<stdio.h>
#include<conio.h>
void table(int);
int getnos();
void main()
{
clrscr();
table(getnos());
getch();
}
int getnos()
{
int a;
printf("Enter the no for table");
scanf("%d",&a);
return a;
}
void table(int l)
{
int i,b;
for(i=0;i<=20;i++)
{
b=l*i;
printf("\n%d x %d = %d",l,i,b);
}
}
// Create a function to fill-up the screen with horizontal line.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void line();
void main()
{
clrscr();
line();
getch();
}
void line()
{
int i;
for(i=0;i<80;i++)
{
printf("_");
delay(100);
}
}
// Create a function to show names so many times.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void show();
void main()
{
clrscr();
show();
getch();
}
void show()
{
int i,x;
char name[20];
printf("What is your Name");
scanf("%s",name);
fflush(stdin); // to flush the buffer.
printf("how many times");
scanf("%d",&x);
for(i=0;i<x;i++)
{
printf("\nMy Name is %s",name);
delay(100);
}
}
// Create a function to square and cube a number of using your own function.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
float square(float);
float cube(float);
float no();
void main()
{
float x;
clrscr();
x=no();
printf("The Square of the No = %f",square(x));
printf("\nThe Cube of the No = %f",cube(x));
getch();
}
float square(float i)
{
float x;
x=i*i;
return x;
}
float cube(float i)
{
float x;
x=i*i*i;
return x;
}
float no()
{
float p;
printf("Please enter a no");
scanf("%f",&p);
return p;
}
//Function to point out each digit specified by a group of digits as number
#include<stdio.h>
#include<conio.h>
void eachdigits(long int);
long int getnos();
void main()
{
long int a;
clrscr();
a=getnos();
eachdigits(a);
getch();
}
long int getnos()
{
long int x;
printf ("Enter a no");
scanf("%ld",&x);
return x;
}
void eachdigits(long int x)
{
int b=0, i=1;
while(x!=0)
{
b=x%10;
x=x/10;
printf("\n%d digit =%d",i,b);
i++;
}
}
//Function to get last digit and first digit of specified group of digit.
#include<stdio.h>
#include<conio.h>
long int no();
void lastandfirst(long int);
void main()
{
long int x;
clrscr();
x=no();
lastandfirst(x);
getch();
}
long int no()
{
long int x ;
printf ( "enter a no ");
scanf ( "%ld", &x);
return x;
}
void lastandfirst(long int x)
{
int f,l;
l=x%10;
while (x!=0)
{
f=x%10;
x=x/10;
}
printf ("last digit =%d in first digit = %d",l,f);
}
//Write a function to show the greatest number among the specified nos.
# include<stdio.h>
# include<conio.h>
# include<stdlib.h>
void greatest ();
int input();
int gtest;
void main()
{
clrscr();
input();
printf ( "greatest no=%d", gtest);
getch();
}
int input ()
{
int i,no,x;
int b=-32767;
printf ( "how many nos");
scanf ("%d",&i);
for ( x=0 ; x< i ; x++)
{
printf( "enter a no ");
scanf ( "%d", &no);
if (no > b)
{
b=no;
}
}
gtest =b;
return 0;
}
//Write a function to show the greatest number among the specified nos.
# include<stdio.h>
# include<conio.h>
# include<stdlib.h>
int input();
int loest;
void main()
{
clrscr();
input();
printf ( "Lowest no=%d", loest);
getch();
}
int input ()
{
int i,no,x;
int b=32767;
printf ( "how many nos");
scanf ("%d",&i);
for ( x=0 ; x< i ; x++)
{
printf( "enter a no ");
scanf ( "%d", &no);
if (no < b)
{
b=no;
}
}
loest =b;
return 0;
}
//Write a function to show and calculate the retail price in given cost, carrying cost, vat, //and profit percentage.
# include<stdio.h>
# include<conio.h>
# include<stdlib.h>
float getnos();
float calculate(float);
float getnos()
{
float cost;
printf("Enter the cost");
scanf("%f",&cost);
return cost;
}
float calculate(float c)
{
float cc,vat,profit,rp;
cc=c*.1;
vat=c*.04;
profit=c*.35;
rp=c+cc+vat+profit;
printf("Cost = %.2f",c);
printf("\nCarring Cost = %.2f",cc);
printf("\nVAT = %.2f",vat);
printf("\nProfit = %.2f",profit);
printf("\nRetail Price = %.2f",rp);
return 0;
}
void main()
{
float a;
clrscr();
a= getnos();
calculate(a);
getch();
}
//Write a function is print Fibonacci series for 10 steps.
#include<stdio.h>
#include<conio.h>
void fibo();
void main()
{
clrscr();
fibo();
getch();
}
void fibo()
{
int c=1,d=0,b=0,e=0;
printf("\n%d",d);
printf("\n%d",c);
while(b<=10)
{
e=d+c;
printf("\n%d",e);
d=c;
c=e;
b=b+1;
}
}
// Create a function to convert temperature from Fahrenheit to Celsius.
#include<stdio.h>
#include<conio.h>
float gettmp();
void ftoc(float);
void main()
{
int tmp;
clrscr();
tmp=gettmp();
ftoc(tmp);
getch();
}
float gettmp()
{
float ft;
printf("Enter Fahrenheit Temperature");
scanf("%f",&ft);
return ft;
}
void ftoc(float t)
{
float c;
c=(5*t-160)/9;
printf("Celcius Temperature =%.2f",c);
}
// Create a function to reverse a no.
#include<stdio.h>
#include<conio.h>
long int gettheno();
void reverse(long int);
void main()
{
long int no;
clrscr();
no=gettheno();
reverse(no);
getch();
}
long int gettheno()
{
long int xno;
printf("Enter a no");
scanf("%ld",&xno);
return xno;
}
void reverse(long int xno)
{
long int b=0;
while(xno!=0)
{
b=b*10+xno%10;
xno=xno/10;
}
printf("\nReverse of the no = %ld",b);
}
// Create a function to count the digits.
#include<stdio.h>
#include<conio.h>
long int gettheno();
void countit(long int);
void main()
{
long int no;
clrscr();
no=gettheno();
countit(no);
getch();
}
long int gettheno()
{
long int xno;
printf("Enter a no");
scanf("%ld",&xno);
return xno;
}
void countit(long int xno)
{
long int b=0;
while(xno!=0)
{
b=b+1;
xno=xno/10;
}
printf("\nno of digits = %ld",b);
}
OUTER FILE FUNCTIONS
// User Defined Outer File Without Argument Function
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
getno();
addno();
showno();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int getno(); // Prototype Declaration
int addno();
int showno();
int a,b,c; // Global Variable
/* Outer file function declarations*/
int getno()
{
printf("Enter Two Numbers ");
scanf("%d%d",&a,&b);
return 0;
}
int addno()
{
c=a+b;
return 0;
}
int showno()
{
printf("%d + %d = %d\n",a,b,c);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File Without Argument Function( Without Return)
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
getno();
addno();
showno();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
void getno();
void addno();
void showno();
int a,b,c; // Global Variable
/* Outer file function declarations*/
void getno()
{
printf("Enter Two Numbers ");
scanf("%d%d",&a,&b);
}
void addno()
{
c=a+b;
}
void showno()
{
printf("%d + %d = %d\n",a,b,c);
printf("\nPress Any Key to Exit............");
}
// User Defined Inner File With Argument Function
Save the File As: file1.c
#include “func.tce”
void main()
{
int a,b,c;
clrscr();
a=getno();
b=getno();
c=addno(a,b);
showno(c);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
int showno(int);
/* Outer file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int z;
z=m+n;
return z;
}
int showno(int k)
{
printf("Addition of the Numbers = %d\n",k);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File With Argument Function Using Same Variables
Save the File As: file1.c
#include “func.tce”
void main()
{
int a,b,c;
clrscr();
a=getno();
b=getno();
c=addno(a,b);
showno(c);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
int showno(int);
/* Outer file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int x;
x=m+n;
return x;
}
int showno(int x)
{
printf("Addition of the Numbers = %d\n",x);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File With Argument Function Using no Variables in main
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
addno(getno(),getno());
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
/* Outer file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int x;
x=m+n;
printf("%d + %d = %d\n",n,m,x);
printf("\nPress Any Key to Exit............");
return 0;
}
// User Defined Inner File With Argument Function Calling Another Function
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
showno();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
void showno();
/* Outer file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
int addno(int m,int n) // Pseudo Variables
{
int x;
x=m+n;
printf("%d + %d = %d\n",m,n,x);
printf("\nPress Any Key to Exit............");
return 0;
}
void showno()
{
int a,b;
a=getno();
b=getno();
addno(a,b);
}
// Inner File Function Using If To Accept Or Reject Password
Save the File As: file1.c
#include “func.tce”
void main()
{
int x=0;
clrscr();
x=getno();
password(x);
getch();
}
Save the File As: func.tce
#include<stdio.h>
int password(int);
int getno();
int no();
int addno(int, int);
int showno();
int password(int m)
{
int a,b;
if (m==12345)
{
printf("\nPassword Accepted .....\n");
a=no();
b=no();
addno(a,b);
}
else
{
printf("\nAccess Denied.....\nBetter Luck For Next Time.");
printf("\nPress Any Key to Exit............");
}
return 0;
}
int addno(int a,int b)
{
int c;
c=a+b;
showno(c);
return 0;
}
int showno(int c)
{
printf("Addition = %d\n",c);
printf("\nPress Any Key to Exit............");
return 0;
}
int getno()
{
int a;
printf("Enter Two Password= ");
scanf("%d",&a);
return a;
}
int no()
{
int a;
printf("Enter No ");
scanf("%d",&a);
return a;
}
// User Defined Inner File With Argument Function Calling Another Function to add, sub, //multi and div
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
showno();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int getno();
int addno(int,int);
int subno(int,int);
int mulno(int,int);
int divno(float,float);
void showno();
/* Outer file function declarations*/
int getno()
{
int x;
printf("Enter Number ");
scanf("%d",&x);
return x;
}
void showno()
{
int a,b;
a=getno();
b=getno();
addno(a,b);
subno(a,b);
mulno(a,b);
divno(a,b);
printf("\nPress Any Key to Exit............");
}
int addno(int m,int n)
{
int x;
x=m+n;
printf("\n%d + %d = %d\n",m,n,x);
return 0;
}
int subno(int m,int n)
{
int x;
x=m-n;
printf("\n%d - %d = %d\n",m,n,x);
return 0;
}
int mulno(int m,int n)
{
int x;
x=m*n;
printf("\n%d x %d = %d\n",m,n,x);
return 0;
}
int divno(float m,float n)
{
float x;
x=m/n;
printf("\n%.2f / %.2f = %f\n",m,n,x);
return 0;
}
//Write A Function Enter A Number In Decimal And Convert It To Binary Equivalent.
Save the File As: file1.c
#include “func.tce”
void main()
{
long int a;
clrscr();
a=getno();
convert(a);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
long int convert(long int);
long int getno();
long int convert(long int n)
{
long int s=1,a,b=0;
while(n!=0)
{
a=n%2;
b=b+a*s;
s=s*10;
n=n/2;
}
printf("Result=%ld",b);
return b;
}
long int getno()
{
long int x;
printf("Enter a no in decimal= ");
scanf("%ld",&x);
return x;
}
// Create A Function To Convert Temperature From Celsius To Fahrenheit.
Save the File As: file1.c
#include “func.tce”
void main()
{
int tmp;
clrscr();
tmp=gettmp();
ctof(tmp);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
float gettmp();
void ctof(float);
float gettmp()
{
float ft;
printf("Enter Celcius Temperature");
scanf("%f",&ft);
return ft;
}
void ctof(float t)
{
float f;
f=(9*t+160)/5;
printf("Fahrenheit Temperature =%.2f",f);
}
// Create A Function To Find All Odd And Even Number In A Specified Nos.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
getno();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
int oddcount=0, evencount=0;
int getno();
void odd_even(int);
int getno()
{
int no,x,i;
printf("How many nos");
scanf("%d",&x);
for(i=0;i<=x;i++)
{
printf("\nEnter a no");
scanf("%d",&no);
odd_even(no);
}
no=0;
return 0;
}
void odd_even(int m)
{
if(m%2==0)
{
evencount++;
}
else
{
oddcount++;
}
printf("Odd Numbers = %d\nEven Numbers = %d",oddcount,evencount);
}
// Create A Function To Calculate The Simple Interest On Principle, Rate , Time.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
getnos();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
float si(float, float, int);
float amt(float, float);
void getnos();
void getnos()
{
float p,r,m;
int t;
printf("Enter Principle");
scanf("%f",&p);
printf("Enter Rate");
scanf("%f",&r);
printf("Enter time in Year");
scanf("%d",&t);
m=si(p,r,t);
printf("Simple interest = %f",m);
printf("\nFinal Amount = %f",amt(p,m));
}
float si(float p, float r , int t)
{
float si;
si=p*r*t/100;
return si;
}
float amt(float m, float n)
{
float x;
x=m+n;
return x;
}
// Create a function to calculate the perfect triangle or not.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
ptria(getnos(),getnos(),getnos());
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
void ptria(int,int,int);
int getnos();
int getnos()
{
int a;
printf("Enter the triangle");
scanf("%d",&a);
return a;
}
void ptria(int l, int b , int h)
{
if((l+b+h)==180)
{
printf("Perfect Triangle");
}
else
{
printf("Not a Perfect Triangle");
}
}
// Create a function to calculate the table of a number.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
table(getnos());
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
void table(int);
int getnos();
int getnos()
{
int a;
printf("Enter the no for table");
scanf("%d",&a);
return a;
}
void table(int l)
{
int i,b;
for(i=0;i<=20;i++)
{
b=l*i;
printf("\n%d x %d = %d",l,i,b);
}
}
// Create a function to fill-up the screen with horizontal line.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
line();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void line();
void line()
{
int i;
for(i=0;i<80;i++)
{
printf("_");
delay(100);
}
}
// Create a function to show names so many times.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
show();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void show();
void show()
{
int i,x;
char name[20];
printf("What is your Name");
scanf("%s",name);
fflush(stdin); // to flush the buffer.
printf("how many times");
scanf("%d",&x);
for(i=0;i<x;i++)
{
printf("\nMy Name is %s",name);
delay(100);
}
}
// Create a function to square and cube a number of using your own function.
Save the File As: file1.c
#include “func.tce”
void main()
{
float x;
clrscr();
x=no();
printf("The Square of the No = %f",square(x));
printf("\nThe Cube of the No = %f",cube(x));
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
float square(float);
float cube(float);
float no();
float square(float i)
{
float x;
x=i*i;
return x;
}
float cube(float i)
{
float x;
x=i*i*i;
return x;
}
float no()
{
float p;
printf("Please enter a no");
scanf("%f",&p);
return p;
}
//Function to point out each digit specified by a group of digits as number
Save the File As: file1.c
#include “func.tce”
void main()
{
long int a;
clrscr();
a=getnos();
eachdigits(a);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
void eachdigits(long int);
long int getnos();
long int getnos()
{
long int x;
printf ("Enter a no");
scanf("%ld",&x);
return x;
}
void eachdigits(long int x)
{
int b=0, i=1;
while(x!=0)
{
b=x%10;
x=x/10;
printf("\n%d digit =%d",i,b);
i++;
}
}
//Function to get last digit and first digit of specified group of digit.
Save the File As: file1.c
#include “func.tce”
void main()
{
long int x;
clrscr();
x=no();
lastandfirst(x);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
long int no();
void lastandfirst(long int);
long int no()
{
long int x ;
printf ( "enter a no ");
scanf ( "%ld", &x);
return x;
}
void lastandfirst(long int x)
{
int f,l;
l=x%10;
while (x!=0)
{
f=x%10;
x=x/10;
}
printf ("last digit =%d in first digit = %d",l,f);
}
//Write a function to show the greatest number among the specified nos.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
input();
printf ( "greatest no=%d", gtest);
getch();
}
Save the File As: func.tce
# include<stdio.h>
# include<conio.h>
# include<stdlib.h>
void greatest ();
int input();
int gtest;
int input ()
{
int i,no,x;
int b=-32767;
printf ( "how many nos");
scanf ("%d",&i);
for ( x=0 ; x< i ; x++)
{
printf( "enter a no ");
scanf ( "%d", &no);
if (no > b)
{
b=no;
}
}
gtest =b;
return 0;
}
//Write a function to show the greatest number among the specified nos.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
input();
printf ( "Lowest no=%d", loest);
getch();
}
Save the File As: func.tce
# include<stdio.h>
# include<conio.h>
# include<stdlib.h>
int input();
int loest;
int input ()
{
int i,no,x;
int b=32767;
printf ( "how many nos");
scanf ("%d",&i);
for ( x=0 ; x< i ; x++)
{
printf( "enter a no ");
scanf ( "%d", &no);
if (no < b)
{
b=no;
}
}
loest =b;
return 0;
}
//Write a function to show and calculate the retail price in given cost, carrying cost, vat, //and profit percentage.
Save the File As: func.tce
# include<stdio.h>
# include<conio.h>
# include<stdlib.h>
float getnos();
float calculate(float);
float getnos()
{
float cost;
printf("Enter the cost");
scanf("%f",&cost);
return cost;
}
float calculate(float c)
{
float cc,vat,profit,rp;
cc=c*.1;
vat=c*.04;
profit=c*.35;
rp=c+cc+vat+profit;
printf("Cost = %.2f",c);
printf("\nCarring Cost = %.2f",cc);
printf("\nVAT = %.2f",vat);
printf("\nProfit = %.2f",profit);
printf("\nRetail Price = %.2f",rp);
return 0;
}
Save the File As: file1.c
#include “func.tce”
void main()
{
float a;
clrscr();
a= getnos();
calculate(a);
getch();
}
//Write a function is print Fibonacci series for 10 steps.
Save the File As: file1.c
#include “func.tce”
void main()
{
clrscr();
fibo();
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
void fibo();
void fibo()
{
int c=1,d=0,b=0,e=0;
printf("\n%d",d);
printf("\n%d",c);
while(b<=10)
{
e=d+c;
printf("\n%d",e);
d=c;
c=e;
b=b+1;
}
}
// Create a function to convert temperature from Fahrenheit to Celsius.
Save the File As: file1.c
#include “func.tce”
void main()
{
int tmp;
clrscr();
tmp=gettmp();
ftoc(tmp);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
float gettmp();
void ftoc(float);
float gettmp()
{
float ft;
printf("Enter Fahrenheit Temperature");
scanf("%f",&ft);
return ft;
}
void ftoc(float t)
{
float c;
c=(5*t-160)/9;
printf("Celcius Temperature =%.2f",c);
}
// Create a function to reverse a no.
Save the File As: file1.c
#include “func.tce”
void main()
{
long int no;
clrscr();
no=gettheno();
reverse(no);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
long int gettheno();
void reverse(long int);
long int gettheno()
{
long int xno;
printf("Enter a no");
scanf("%ld",&xno);
return xno;
}
void reverse(long int xno)
{
long int b=0;
while(xno!=0)
{
b=b*10+xno%10;
xno=xno/10;
}
printf("\nReverse of the no = %ld",b);
}
// Create a function to count the digits.
Save the File As: file1.c
#include “func.tce”
void main()
{
long int no;
clrscr();
no=gettheno();
countit(no);
getch();
}
Save the File As: func.tce
#include<stdio.h>
#include<conio.h>
long int gettheno();
void countit(long int);
long int gettheno()
{
long int xno;
printf("Enter a no");
scanf("%ld",&xno);
return xno;
}
void countit(long int xno)
{
long int b=0;
while(xno!=0)
{
b=b+1;
xno=xno/10;
}
printf("\nno of digits = %ld",b);
}
No comments:
Post a Comment