Tutorials
This page contain some Interesting C Projectsand Tutorials Links of our site

Dynamic Chart In Jsp Part-2
Dynamic Chart In Jsp/Create chart in jsp Part-1
Print a particular area of a page using javascript
|
|
Print current time using java in jsp page
Retrieve database table values in loop using jsp
Read data from xml and show in jsp page project download
Previous Year Anna University Question banks
How to use batch update in java and jsp
linking two or more pages from radio button using javascript
Display current time and date in your Jsp page
how to check value is number or not using Javascript
How to pass and get values in href as parameters in Jsp
Retrieve values between two numbers in mysql
how to export a csv using INTO syntax of mysql
using session to protect a page in jsp
Setting Environment Variable in XP
Hibernate Errors and Solutions
Anna University Question Papers
C code for Payroll Processing using File and Structure
#include<conio.h>
struct payroll
{
char name[20];
int basic;
float hra;
float da;
float ta;
float pf;
int salary;
};
struct payroll p1;
void main()
{
FILE *f;
char *filename,a,c2;
clrscr();
f=fopen(”input.txt”,”w”);
printf(”This is payroll Project\n\n”);
printf(”Enter the employee name\n\n”);
scanf(”%s”,p1.name);
a==p1.name;
putc(a,f);
fclose(f);
f=fopen(”input.txt”,”a”);
printf(”Enter the Basic salary\n”);
scanf(”%d”,&p1.basic);
printf(”Employee name:%s\n”,p1.name);
fprintf(f,”Employee name:%s\n”,p1.name);
p1.hra=1.3*p1.basic/100;
p1.ta=1.4*p1.basic/100;
p1.da=1.2*p1.basic/100;
p1.pf=1.0*p1.basic/100;
p1.salary=p1.basic+p1.hra+p1.ta+p1.da-p1.pf;
printf(”Your Actual salary is\t%d”,p1.salary);
fprintf(f,”Your Actual salary is\t%d”,p1.salary);
fclose(f);
getch();
}
C code for Bank deposit,withdraw operations
#include
char cname[20];
float amt;
int x;
int cnum;
void new()
{
printf(”Enter the customer name\n”);
scanf(”%s”,cname);
printf(”Enter the customer number\n”);
scanf(”%d”,&cnum);
printf(”Enter the deposit amount\n”);
scanf(”%f”,&amt);
getch();
}
void deposit()
{
int num;
float depos;
printf(”Enter the customer number\n”);
scanf(”%d”,&num);
if(num!=cnum)
{
printf(”Invalid customer number\n”);
}
else
{
printf(”Pleae enter the deposit amount\n”);
scanf(”%f”,&depos);
amt=amt+depos;
}
getch();
}
void withdraw()
{
int num;
float withdraw;
printf(”enter the customer number\n”);
scanf(”%d”,&num);
if(num!=cnum)
{
printf(”Invalid customer number\n”);
}
else
{
printf(”Enter the withdraw amount\n”);
scanf(”%f”,&withdraw);
}
if((withdraw+100)
{
amt=amt-withdraw;
printf(”Amount is withdrawn\n”);
}
else
{
printf(”Insufficient balance\n”);
printf(”Amount you can withdrawn is%f”,amt-100);
}
getch();
}
void balance()
{
int num;
printf(”Enter the customr number\n”);
scanf(”%d”,&num);
if(num!=cnum)
{
printf(”Invalid customer number\n”);
}
else
{
printf(”The current balance is%f”,amt);
}
getch();
}
void main()
{
int n;
for(;;)
{
clrscr();
printf(”1.New\n”);
printf(”2.Deposit\n”);
printf(”3.Withdraw\n”);
printf(”4.Balance\n”);
printf(”5.Exit\n”);
printf(”Enter your choice\n”);
scanf(”%d”,&n);
switch(n)
{
case 1:
new();
break;
case 2:
deposit();
break;
case 3:
withdraw();
break;
case 4:
balance();
break;
case 5:
exit(0);
}
}
}
limitations and assumptions:
1. the strings are separated by spaces.
2. the carriage return CR decides the end of entries
3. the string length can be varied by changing
#define MAXSTRLEN 20
4. the max number of strings can be varied by changing
# define MAXSTR 100
5. Program done using only standard C.
6. Bubble sort used for sorting. You can use other sorts.
*/
#include
#include
#include
#define MAXSTRLEN 20
#define MAXSTR 100
void main()
{
struct sarr2
{
char sarr1[MAXSTRLEN];
int num;
}sarray2[MAXSTR];
char ch=’ ‘,prevch=’ ‘,sarray[MAXSTR][MAXSTRLEN],tempstr[MAXSTRLEN];
int i=0,j=0,numstr=0,count=0,tempnum=0;
printf(”\n enter : “);
do
{
ch=getche();
if (ch!=’\r’)
{
if(ch==’ ‘)
{
if (prevch!=’ ‘)
{
i++;
j=0;
}
prevch=ch;
}
else if (ch!=’ ‘)
{
sarray[i][j]=ch;
prevch=ch;
j++;
}
}
}while(ch!=’\r’);
numstr=i;
if(ch==’\r’) printf(”\n\nEnter pressed, number of strings=%d “, numstr+1);
/*
sort sarray
*/
for(i=0;i<=numstr-1;i++)
for(j=i+1;j<=numstr;j++)
{
if (strcmp(sarray[i],sarray[j])>0)
{
strcpy(tempstr,sarray[i]);
strcpy(sarray[i],sarray[j]);
strcpy(sarray[j],tempstr);
}
}
/*
Initialise the array 2
*/
for(i=0;i
strcpy(sarray2[i].sarr1," \0");
sarray2[i].num=0;
}
printf("\n\n The entered sorted strings in array and counting occurences...\n");
strcpy(tempstr,sarray[0]);
count=0;
j=0;
for(i=0;i<=numstr;i++)
{
printf(" %s",sarray[i]);
if (strcmp(tempstr,sarray[i])==0)
{
count++;
strcpy(sarray2[j].sarr1,tempstr);
sarray2[j].num=count;
}
else if (strcmp(tempstr,sarray[i])!=0)
{
count=1;
j++;
strcpy(tempstr,sarray[i]);
strcpy(sarray2[j].sarr1,tempstr);
sarray2[j].num=count;
}
}
count=j;
for(i=0;i<=count-1;i++)
for(j=i+1;j<=count;j++)
{
if (sarray2[i].num
strcpy(tempstr,sarray2[i].sarr1);
strcpy(sarray2[i].sarr1,sarray2[j].sarr1);
strcpy(sarray2[j].sarr1,tempstr);
tempnum=sarray2[i].num;
sarray2[i].num=sarray2[j].num;
sarray2[j].num=tempnum;
}
}
printf("\n\n The strings and occurences ");
for(i=0;i<=count;i++)
{
printf("\n%s = %d ",sarray2[i].sarr1,sarray2[i].num);
}
printf("\n\n Press any key ... ");
getch();
}
C Program to convert numbers into words
1. Converts Numerical amount to Rs. & paise only.
2. Limitations… upto 99 crores.
3. Use : you can use it in your billing program etc. by adapting
the ‘main()’ function.
4. Is self explanatory .
5. Is freeware.But do let us know by e-mail if you use the code
in your programs.
6. You use this program at your own risk. It is your responsibility
to check out the code / program.
*/
#include
long float numberf=0,numberpaisef=0,numberpf2;
long int numberpaise=0 ;
long int number=0,number2=0,numrem1=0,numrem2=0;
int flagfinish=0,i=0,j=0 ;
char numberstr[50];
char rsinword[151],rsinword2[51],rsinword3[51],rsinword4[51] ;
void proc_rs3(void);
void proc_rs4(void);
long int get_therem(long int x,long int y);
long int func_rs2(long int x,long int y);
void main()
{
printf(”Enter Number : “) ;
scanf(”%lf”,&numberf) ;
flagfinish = 0 ;
numberpaisef=(numberf*100.0);
number = (long int)(numberf) ;
numberpf2=(number)*100;
numberpaisef=numberpaisef-numberpf2+0.5;
numberpaise= (long int)(numberpaisef);
/* numberpaise = int((numberf*100) % 100 );*/
/* printf(”\nNumbers : 1: %f, 2: %f 3: %f\n”, numberf,numberpf2,numberpaisef) ; */
/* printf(”\nNumbers : 1: %ld 2: %ld\n”, number,numberpaise) ; */
/* flagfinish set to 1 so comes out of loop */
if (number > 0)
{
strcpy(rsinword,”Rupees “);
while (flagfinish == 0)
{
if (number >= 10000000 && number <= 999999999)
{
number2 = 10000000 ;
numrem1 = func_rs2(number,number2) ;
proc_rs3() ;
strcat(rsinword," Crore");
number = get_therem(number,number2) ;
}
else if (number >= 100000 && number <= 9999999)
{
number2 =100000 ;
numrem1=func_rs2(number,number2) ;
proc_rs3() ;
strcat(rsinword," Lakh") ;
number = get_therem(number,number2) ;
}
else if (number >= 1000 && number <= 99999)
{
number2 =1000 ;
numrem1=func_rs2(number,number2) ;
proc_rs3() ;
strcat(rsinword," Thousand") ;
number = get_therem(number,number2) ;
}
else if (number >= 100 && number <= 999)
{
number2 =100 ;
numrem1=func_rs2(number,number2) ;
proc_rs3() ;
strcat(rsinword," Hundred") ;
number = get_therem(number,number2) ;
}
else if (number >= 10 && number <= 99)
{
numrem1=number ;
proc_rs3() ;
flagfinish = 1 ;
}
else if (number >= 1 && number <= 9)
{
numrem1 = number ;
proc_rs3() ;
flagfinish = 1 ;
}
else if (number<=0)
{
flagfinish = 1 ;
}
} /* end of while loop */
} /* end of if construct */
if (numberpaise!=0)
{
strcat(rsinword," and Paise ") ;
if (numberpaise >= 10 && numberpaise <= 99)
{
numrem1=numberpaise;
printf("\n %d",numrem1);
proc_rs3();
flagfinish=1;
}
if (numberpaise >= 1 && numberpaise <= 9)
{
numrem1=numberpaise;
printf("\n %d",numrem1);
proc_rs3();
flagfinish=1;
}
} /* end of if */
strcat(rsinword," Only");
if (strlen(rsinword)<=50)
{
for(i = 0,j = 0 ;i < strlen(rsinword); i++,j++)
{
rsinword2[j] = rsinword[i];
}
}/* if 50 */
if ( (strlen(rsinword)>50) && (strlen(rsinword)<=100) )
{
for(i = 0,j = 0 ;i < 50; i++,j++)
{
rsinword2[j] = rsinword[i];
}
for(i = 50,j = 0 ;i < strlen(rsinword); i++,j++)
{
rsinword3[j] = rsinword[i];
}
}/* if 100 */
if ( (strlen(rsinword)>100) && (strlen(rsinword)<=150) )
{
for(i = 0,j = 0 ;i < 50; i++,j++)
{
rsinword2[j] = rsinword[i];
}
for(i = 50,j = 0 ;i < 100; i++,j++)
{
rsinword3[j] = rsinword[i];
}
for(i = 100,j = 0 ;i < strlen(rsinword); i++,j++)
{
rsinword4[j] = rsinword[i];
}
}/* if 150 */
printf("\n %f",numberf);
printf("\n %s",rsinword2);
printf("\n %s",rsinword3);
printf("\n %s",rsinword4);
} /* end of function main() */
long int func_rs2(long int x,long int y)
{
return (long int) x/y;
}
void proc_rs3(void)
{
switch (numrem1)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
numrem2=numrem1;
proc_rs4();
break;
case 10:
strcat(rsinword," Ten") ;
break;
case 11:
strcat(rsinword," Eleven") ;
break;
case 12:
strcat(rsinword," Twelve");
break;
case 13:
strcat(rsinword," Thirteen");
break;
case 14:
strcat(rsinword," Fourteen");
break;
case 15:
strcat(rsinword," Fifteen");
break;
case 16:
strcat(rsinword," Sixteen");
break;
case 17:
strcat(rsinword," Seventeen");
break;
case 18:
strcat(rsinword," Eighteen");
break;
case 19:
strcat(rsinword," Nineteen");
break;
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
strcat(rsinword," Twenty");
if (numrem1 >= 21)
{
numrem2=numrem1 % 10;
proc_rs4();
}
break;
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
strcat(rsinword,” Thirty”) ;
if (numrem1 >= 31)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
strcat(rsinword,” Forty”) ;
if (numrem1 >= 41)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59:
strcat(rsinword,” Fifty”) ;
if (numrem1 >= 51)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67:
case 68:
case 69:
strcat(rsinword,” Sixty”) ;
if (numrem1 >= 61)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
strcat(rsinword,” Seventy”) ;
if (numrem1 >= 71)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
strcat(rsinword,” Eighty”) ;
if (numrem1 >= 81)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
strcat(rsinword,” Ninety”) ;
if (numrem1 >= 91)
{
numrem2=numrem1 % 10 ;
proc_rs4() ;
}
break;
} /*switch*/
}/* end of function proc_rs3 */
void proc_rs4(void)
{
switch (numrem2)
{
case 1 : strcat(rsinword,” One”) ;
break;
case 2 : strcat(rsinword,” Two”);
break;
case 3 : strcat(rsinword,” Three”);
break;
case 4 : strcat(rsinword,” Four”);
break;
case 5 : strcat(rsinword,” Five”);
break;
case 6 : strcat(rsinword,” Six”);
break;
case 7 : strcat(rsinword,” Seven”);
break;
case 8 : strcat(rsinword,” Eight”);
break;
case 9 : strcat(rsinword,” Nine”);
break;
} /* end of switch*/
} /* end of function proc_rs4 */
long int get_therem(long int x,long int y)
{
return (long int)(x % y) ;
}
C Program to read number of words,sentences,lines,symbols in a text file
1.Displays the number of words,sentences,lines,paragraphs,symbols in a pure text file
2.The program assumes that the file path is fixed… filename should exist in this fixed file path
& be 8 char.(max.) for primary name & 3 char. (max.) for the extension.
You can modify the Filepath by changing the filepath in the program below to the directory of your choice.
3. If the Text file has more than 22 lines, the program pauses the display to show screenful at a time.
4. Is self explanatory .
5. Is freeware.But do let us know by e-mail if you use the code
in your programs.
6. You use this program at your own risk. It is your responsibility
to check out the code / program.
*/
#include
#include
#include
void main()
{
int wrdctr,sentctr,symbctr,paractr,lctr,countchars1;
int wflg,sflg,syflg,newlineflg,syflg2;
FILE *fp;
char char1;
char fname1[13],fname2[70];
wrdctr = sentctr = symbctr = paractr = lctr = countchars1 = 0;
wflg = sflg = syflg = newlineflg = syflg2= 0;
clrscr();
wflg=0;
sflg=0;
printf(”Enter file [pure text file...] : “) ;
gets(fname1);
printf(”The File Contents & Statistics are…\n\n”);
strcpy(fname2,”c:\\”);
strcat(fname2,fname1);
if ((fp = fopen(fname2,”r”)) == NULL)
{
fprintf(stderr,”Error Opening File “);
getch();
exit(1);
}
countchars1 = 0;
while(!feof(fp))
{
fscanf(fp,”%c”,&char1);
if (countchars1==0)
{
if(char1 == ‘ ‘|| char1 == ‘\t’)
{
wflg = 1;
}
if(char1 == ‘.’ || char1 == ‘?’ || char1 == ‘!’)
{
sflg = 1;
wflg = 1;
}
}
countchars1++;
if(char1 == ‘ ‘ || char1 == ‘\t’)
{
if(wflg == 0)
{
wflg = 1;
wrdctr++;
}
}
if(char1 == ‘.’ || char1 == ‘?’ || char1 == ‘!’)
{
if(sflg == 0 && countchars1 != 0)
{
sflg = 1;
sentctr++;
if(wflg == 0)
{
wflg = 1;
wrdctr++;
}
}
}
if(char1 == ‘\n’)
{
lctr++;
if(lctr % 22 == 0)
{
printf(”\n << Press any key to continue ... >>”);
getch(); /*shows one screen at a time */
}
if ((sflg==1)&&(newlineflg==0))
{
paractr++;
newlineflg = 1;
}
if(wflg == 0)
{
wrdctr++;
}
}
/*char1 == ‘\” || char1 == ‘\”‘ || char1 == ‘\\’)*/
if(char1 == ‘(’ || char1 == ‘)’ || char1 == ‘[' ||
char1 == ']‘ || char1 == ‘{’ || char1 == ‘}’ ||
char1 == ‘+’ || char1 == ‘-’ || char1 == ‘/’ ||
char1 == ‘*’ || char1 == ‘%’ || char1 == ‘=’ ||
char1 == ‘>’ || char1 == ‘<' || char1 == ':' ||
char1 == ';' || char1 == '$' || char1 == ',' ||
char1 == '#' || char1 == '^' || char1 == '|' ||
char1 == '~' || char1 == '`' || char1 == '@' ||
char1 == '\\')
{
if ((wflg==0)&&(syflg==0))
{
wrdctr++;
}
syflg = 1;
symbctr++;
}
if (char1=='\'' || char1=='\"')
{
syflg=1;
symbctr++;
if (syflg2==1)
{
wrdctr++;
}
if(syflg2==0)
{
syflg2=1;
}
}
if (char1!='\'' && char1!='\"')
{
syflg2=0;
}
/*&& char1 != '\t'*/
/*char1 != '\'' && char1 != '\"' && char1 != '\\'*/
if(char1 != ' ' && char1 != '\t' && char1 != '.' && char1 != '?' && char1 != '!')
{
if(char1 != '(' && char1 != ')' && char1 != '[' &&
char1 != ']' && char1 != '{' && char1 != '}' &&
char1 != '+' && char1 != '-' && char1 != '/' &&
char1 != '*' && char1 != '%' && char1 != '=' &&
char1 != '>‘ && char1 != ‘<' && char1 != ':' &&
char1 != ';' && char1 != '$' && char1 != ',' &&
char1 != '#' && char1 != '^' && char1 != '|' &&
char1 != '~' && char1 != '`' && char1 != '@' &&
char1 != '\'' && char1 != '\"' && char1 != '\\' && char1 != '\n')
{
wflg=0;
if (newlineflg==1)
{
newlineflg=0;
}
}
}
if(char1 != '.' && char1 != '?' && char1 != '!')
{
sflg=0;
}
printf("%c",char1);
} /* end of while loop */
if (countchars1 > 0 && wflg == 0 && sflg==0)
{
wrdctr++;
lctr++;
}
fclose(fp);
printf(”\nFile Statistics :\n”);
printf(”——————–\n”);
printf(”\nNo. Of Characters : %d”,countchars1);
printf(”\nNo. Of Words : %d”,wrdctr);
printf(”\nNo. Of Sentences : %d”,sentctr);
printf(”\nNo. Of Paragraphs : %d”,paractr);
printf(”\nNo. Of Symbols : %d”,symbctr);
printf(”\nNo. Of Lines : %d”,lctr);
printf(”\n Press any key to exit …”);
getch();
} /*end of main() */
Comments Off






