Professional Documents
Culture Documents
printf("Enter your Chemistry number:\n");
scanf("%f",&student[i].chemistry);
student[i].sum = student[i].math + student[i].english + student[i].bangla + stud
ent[i]. chemistry;
student[i].number = (student[i].sum * 0.25);
if((student[i] english>=33 && student[i].math>=33 8% student[i].bangla>=33 && st
udent [i] .chemistry>=33 )){
student[i].result=33;
3
else{
student[i].result=32;
+
+
for(is@sicnsitt){
if( student[i].result >= 33 && student[i].number >=36 ){
fprintf(file,"\n %s Xd", r ,student[i].roll);
fprintf(file,"\n %s %.2#", m, student[i].math);
&
“ ~
~~ ~~Oo
Re
Pac& 28
Rell) 1805032
fprintf(file,"\n %5 %.2#", b, student[i].bangla);
fprintf(file,"\n %s %.2f", e, student[i].english);
fprintf(file,"\n %s %.2f", ¢, student[i] chemistry);
if( student[i].number >= 60.0)
{fprintf(File,"\nXs",one) ;}
else if( (student[i].number >= 45.0) && (student[i].number < 69.0)
{fpnint#(File, "\nks" two) 5}
else
{fprint#( File, "\n%s" three) 3}
+
+
fclose(File);
Problem 53. Create all relevant files on the disk for problem ~ 51 and process therefrom,
Program:
Hncludggyio. >
x x
strc student oO
Nit rol; ~
float english; Ss
float bangla; 9
float math;
float chemistry;
int result;
b
int input(int x)
printf ("Enter number of students: \n")5
scanF("%d" ,&x) 5
return(x);
int main()
FILE *file;
int ni;
file = fopen(“prbs3.txt","a");
char m[] = {"\nFailed in Math};
char b[] = {"\nFailed in Bangla"};
& ce &
a &or
Re
Pag 29
Rell) 1805032
char e[] = {"\nFailed in English"};
char c{] = {"\nFailed in Chenistry"};
char r[] = {"\n\n Report for roll: "};
n = input(n);
struct student student[n];
For(isosicnsit+){
printf("\nEnter your roll:\n");
scanf("Xd" student [i] .rol);
printf ("Enter your Math Number:\n")5
scanf("Kf" ,@student [i] .math) ;
printf ("Enter your English number: \n");
scanf("%F",&student[i].english) ;
printf ("Enter your Bangla nunber
scanf ("%F" ,@student [i] bangla);
printf ("Enter your Chemistry number:\n");
scanF("%F" ,&student[i] chemistry) ;
"95
if((student[i].english < 33 || student[i].math < 33 || student[i].bangla < 33 ||
student[i] chemistry < 33 )){
ident[i].result = 32;
a & &
else{ ~~
student [i].result=33; CY
For (i=Osicnsitt){
if(student[i].result == 32){
fprintf (file, "%s %d",r, student[i].rol1);
if(student[i].math < 33){
fprintf(file, "Xs" , m);
+
if(student[i] english < 33){
fprintf(file, "Xs" , e);
>
if(student[i] bangla < 33){
fprintf(file, "Xs" , b);
+
if(student[i].ch
fprintf (File,
y
dstry < 33){
ws" 5 ¢)3
t
+
&
“ ~
~~ ~~
anit we weOo
ww
Pas& 30
Rell) 1805032
fclose(file);
+
Problem 54, Create a pay roll input file on disk with each record containing the data:
Identification number : ID
Basic salary : B
Allowances : A
vvvyv
Deductions : D
Create necessary files on disk and process to find PF (10%), gross salary and the net salary. Arrange
to save the output file.
Program:
#includecstdio.h>
ae yal
&
basic; oO
Sloat allowance; “ NS
< float deductions; Ss
float pfs 9
float gross;
Float net
Bz
int input(int x)
{
printf ("Enter number of employees: \n");
scant ("%d" 8x) 5
return(x);
+
int main()
{int ni;
n= input(n);
struct student student[n];
FILE *File;
file = fopen(“prbs4.txt","a");
char d[]={"ID: "}5
& 2 &Oo
“NS
Pag O31
Rell) 1805032
={"Net Salary:
PF: *}5
for(i=ojicnjit+){
printf("\nEnter your 1D:
scanf("Xd" ,astudent[1].id);
printf("Enter your Basic Salary:\n");
scanf("%F" ,astudent[i].basic);
printf ("Enter your Allowances: \n");
scanf("%F" ,@student [i] .allowance) ;
printf ("Enter your Deductions: \n");
scanf ("%F" ,@student [i] .deductions) ;
student[i].pf = student[i].basic * .1 ;
student[i].gross = student[i].basic + student[i].allowance;
student[i].net = student[i].gross - student[i].deductions - student[i].pf
+
Fort gypssension)(
R
SS ntf(file, "\n\n%s %d" ,d, student (G}id) 5
Nfprintf(file, “\n%s %f "jp, student[h}. pf); ss
<> fprintf(file, "\n%s %f " jg, stud J.gross); Ss
SY fprintf(file, "\n%s Xf " ns, int[i].net); Q
3
fclose(file);
Problem 55. Use the output file in problem 56 to print the payroll records of persons drawing a gross
salary of TK 7,000/ - or above.
Program:
#include