Tuesday, June 30, 2009

useful tipos and tricks for batch file

Fast Shut Down
Windows XP
1. Go to Start and click on run
2. In the blank Field type Regedit hit the enter button
3. Now expand HKEY_LOCAL_MACHINE
4. Expand SYSTEM
5. Expand ControlSet003
6. Now click on Control DO NOT EXPAND
7. On the right side click on WaitToKillServiceTimeout
8. Has default it should be set to 20000 (this means that it would Shutdown in around 20 seconds)
9. Set it to 5000 (This should cut down your shutdown time)

Windows Vista
1. Go to Start and type Regedit and hit the enter button
2. A Windows needs your Permission to continue should prompt up
3. Click continue Registry Editor should come up
4. Now expand HKEY_LOCAL_MACHINE
5. Expand SYSTEM
6. Expand ControlSet003
7. Now click on Control DO NOT EXPAND
8. On the right side click on WaitToKillServiceTimeout
9. Has default it should be set to 20000 (this means that it would Shutdown in around 20 seconds)
10. Set it to 5000 (This should cut down your shutdown time)

Change Drive Name Through Batch File

1. Login to the PC you are wanting to change the drive letter for.
2. Create a new batch file by right clicking on your desktop and selecting New->Text File. Rename the file to whatever you want but make sure the file extention is .bat.
3. Right click on the file you created and select edit.
4. Place the following code in the file and save. This code will delete the existing drive mapping and move it to another drive letter.
net use /delete
net use \\server\share
5. Double click the saved file and you should see the DOS screen flash. Check to make sure your drive has changed.
How to Write a Batch File
Writing a batch file is used to automate daily and often mundane tasks. Instead of typing the same commands day after day, you would simply double click the batch file to run said commands. These instructions will show you how to do so.
Steps
For Windows
1. Open up Notepad in Windows. You can do this by navigating to Start > Programs > Accessories > Notepad, or simply by entering notepad under Start > Run.
2. Or open up notepad by C:\WINDOWS\system32\notepad.exe
3. Save your file before anything, so be sure to follow the instructions closely.
1. Go to File > Save As... and chose a file name.
2. Choose your desktop as the location to save, for now. Don't click Save just yet.
3. Click on the dropdown menu next to "File name". Select "All files" instead of Text Document".
4. Add .bat to the end of your file name before you save. For example, you would type example.bat.
5. Click on Save. If you did this correctly, you should see your file name in the title of Windows Notepad. Make sure that it reads as example.bat—not example.bat.txt. Now you are ready to create your batch file.
4. Type "@echo off" on the first line of your batch file. This will prevent any spaces in the batch file to be read by the program when executed.
5. Enter your commands. The following example below will show you how to create a batch file that will automatically load wikiHow.com using Internet Explorer.
o @echo off.
o REM The following will open wikiHow.com in a new Internet Explorer window.
o "start Iexplore.exe www.wikihow.com"
o REM The following will open wikiHow.com in your default browser, but if it is IE and you have another IE window open, then it will hijack that window.
o "start www.wikihow.com"
6. Save the file by going to "File>Save" and type in "wikihow.bat".
7. Run the file by double clicking the file on your desktop.

[edit] Tips
• You can use third party editors such as UltraEdit to edit your batch file. But for the most part, these are a waste of time when writing simple batch files.
• Make sure not to enter any quotes used above. Those are simply to help distinguish the command, filename, and file extension.
• You will have to use quotes if you want to open a directory or file with spaces in its name, like start "C:\Documents and Settings\"
• You must click "Save as" and change ".txt" to "All files" in the file type drop-down menu. Then, add ".bat" to your file name instead of ".txt".
• When saving the batch file, type the filename as "filename.bat" without quotation marks, and it's not necessary to select "All Files".
• Batch files can also have a .cmd extension beginning with Windows 2000. There is no difference in operation, but the .cmd files use 32-bit execution while the .bat files use 16-bit execution.



Black Screen prank
1. Open the registry file. Click on the "Start" menu, select "Run", and type in REGEDIT. Click on "Ok" or press [Enter].
2. Navigate to "HKEY_CURRENT_USER\Control Panel\Colors". These give the RGB values for the color of each Windows' component. These will show all of the color values, many of which are not available through the Windows GUI (from "Appearance" tab in "Display Properties").
3. Change each value. The "Data" column holds the RGB value for all component shown here. For each listing that is not set to "0 0 0" in the "Data" column, double-click on it and change it to 0 0 0 with spaces between the zeros. Then click "Ok" or press [Enter].
4. Close the Registry Editor.
5. Restart the computer.


How to Make a Fake Error Message on Windows
This is just a funny prank to pull on your friends using VBScript. You make a fake error message that has a message on it.
Steps

1. Open Notepad. The quickest way is to press WIN-R, and type "notepad.exe" without the quotes.
2. Copy and Paste the following code:lol=msgbox("Your Message Here",16,"Your Title Here")
3. Change Your Message Here to a message, and change Your Title Here to whatever you want to show on the Title Bar. I recommend using Error as a title.
4. Go to File-Save as... and select All Files in the Save as type: and save the file as *.vbs and you're all done!
5. Just double-click on the .vbs file and the error will pop up!

Tuesday, June 16, 2009

Differentiate between Analog and Digital Computer with suitable examples
The difference between Analog and Digital computers are as follow:
Analog Computer
(1) Information is represented by the magnitude of continuously varying signals
(2) They are not accurate as digital computers.
(3) Things done in analog computer can be done in digital computer.
(4) Analog computer is used for scientific research only and it is rarely used.
(5) It needs much mathematical background to use and understand
(6) Plesely, Speedometer, thermometer, seismograph etc
Digital Computer
Information is represented by electronic pulses( "On" or "Off")
They are very much accurate

Things done in digital computer cannot be done in analog computer

Digital computer is widely used even for general purpose

There is no need of much mathematical background to use and understand

Calculater, video games etc.

Explain about the generation of Programming Language

Explain about the generation of Programming Language
Ans: According to the development and modification in programming language, the generation of programming language can be described as :
(i) Machine language: The history of programming language starts with machine language. The only command that computer can understand is the machine code or '0' and '1'.
Machine language consists of bits of 0s and 1s that electrically set the switches, where 0 represents off (or low) and 1 represents on (high voltage). Initially the program used to be written using this language.
(ii) Assembly language: A programming language developed to replace machine code o and 1 is known as assembly language. It consists of many symbols and abbreviation. The program written using this language is converted into machine code by Assembler. The drawback of this language is that the program written for one computer does not work in another computer and it was a tough job for the programmer to remember the codes.
(iii) Procedural Language: General purpose programming languages are called procedural languages or procedure-oriented programming (POP). They are language such as Pascal, BASIC, COBAL and FORTRAN which are designed to express the logic, the procedure of a problem. In the procedure-oriented approach, the problem is viewed as a sequence of things to be done such as reading, calculating and printing. A number of functions are written to accomplish these tasks. The primary focus is on functions. The list of instructions grouped is known as function.
Some characteristics of POP are:
Emphasis is on doing thing(algorithms)
Large programs are divided into smaller programs known as functions.
Most of the functions share global data
Data move openly around the system from function to function.
Functions transform data from one form to another.
Employs top-down approach in program design.
(iv) Problem Oriented Language: Problem oriented languages are designed to solve specific problems or develop specific applications by enabling us to describe what we want rather than step by step procedures (v) Natural Language: Natural languages are still in the development stages, but they promise to have profound effect, particularly in the areas of artificial intelligence and export systems.

#) What do you mean by generation of computers? What technology characterizes the 2nd and 3rd generation of computers? How the limitations of 2nd gene

#) What do you mean by generation of computers? What technology characterizes the 2nd and 3rd generation of computers? How the limitations of 2nd generation computer were addressed by the 3rd generation?
Ans: Evolution of computer is divided into five phases (generation) under the development and improvement in different factors is known as generation. and some of the important factors are: Speed , Storage capacity, Reliability, Cost reduction
SECOND GENERATION
1959-1964
Used transistors (invented-1947, used in computer-1959, electronic switching device)
Transistor=transfer + resistor( Bell Lab-> John Burdeen, Walter Brattain and William Shockley-> Nobel prize 1956
Speed (micro seconds)
High level language i.e. COBOL, BASIC
Magnetic core memory (as internal storage)
Magnetic tapes for secondary storage
Input & output devices faster
IBM 1400, 400 series, NCR 315,
Smaller (How?), cheaper, more reliable
Specialized (scientific, non-scientific)
THIRD GENERATION
1965-1974
IC( by Jack Kilby,1958) used (as electronic circuitry) silicon
Monitors (video display terminals introduced) and keyboards for data out put and input.
Semi conductor memory instead of magnetic core memory (high memory capacity)
Mini computers introduced
Magnetic disks replaced to magnetic tape
Speed (nanoseconds)
Wide use of high level language PASCAL, RPG(Report Program Generator), COBOL, FORTRAN
IBM systemt/360, NCR (century series)
Generalized workSSI (hundreds of transistors) & MSI (thousands of…)

What is System software? Describe the function of it.

What is System software? Describe the function of it.
It is Interface between hardware and Application Software (or User). CPU coordinates with other parts in computer System due to system Software. And the jobs of it are:
To load itself in the memory (RAM) and it is called booting.
To load User program in the memory
To load Data through keyboard to RAM
To Interpret the program instructions one at a time
To display output (gives instruction to display) on the screen (printer too)
To read /write data from/into storage device.
To control hardware (activate when needed)
To act as a manager
To check input/output devices available

#) What is software?

#) What is software?
Ans: Software is abstract machinery that instructs the computer hardware to perform the activities. It provides an interface or link between computer hardware and user. Software can be treated as soul of computer
Software is a module or series of instructions integrated together. A single job assigned by the user can be broken down into .many software instructions. It is a thinking technology. Success of Hardware depends upon the power and capabilities of its supporting software.
Types
· System software
· Application software
· Utility software

What are the different stages of software development?

What are the different stages of software development?
Explain with examples why a program development requires systematic methods. What are the initial steps of program design?
Why should user be involved throughout the system development life cycle? Can you think of some specific examples of what might happen if the users are not involved?
Ans: A set of elements work together for a common goal is known as system i.e. education system, Police Security System, Banking System etc. Raw data is originated, processed / transmitted and received as information and the integration of it is known as information system.
To manage the existing information system by using computer is Computerized Information System(CIS). To manage Information System(MIS) we must know the structure of an organization. The structure of an organization can be leveled top to bottom as STRATEGIC --->TACTICAL ---> OPERATIONAL ---> TRANSACTION. And the data/information flow is more structured in lower level of an organization.
The various steps have to be flowed to develop a system is known as SDLC( System/Software Development Life Cycle) and they are:
SYSTEM ANALYSIS: System analysis is the analysis of the problem that the organization will try to solve with an information system. It consists of defining the problem, identifying its causes, specifying the solution, and identifying the information requirements that must be met by a system solution. The key to building any large information system is a through understanding of the existing organization and system.
FEASIBILITY STUDY: It involves a feasibility study to determine whether that solution is feasible, or achievable, given the organization's resources and constraints. Three major areas of feasibility must be address:
1. Technical Feasibility: Whether the proposed solution can be implemented with the available hardware, software, and technical resources.
2. Economic Feasibility: Whether the benefits of the proposed solution outweigh the costs.
3. Operational Feasibility: Whether the proposed solution is desirable within the existing managerial and organizational framework.
ESTABLISHING INFORMATION REQUIREMENTS :The system analyst has to define the specific information requirements that must be met by the system solution selected. At the most basic level, the information requirements of a new system involve identifying who needs what information, where, when and how. Requirements must consider economic, technical, and time constraints, as well as the goals, procedures, and decision processes of the organization.
SYSTEM DESIGN : System design shows how the system will fulfill the objective. It consists of all the specifications that give the system its form and structure. Information system design is an exacting and creative task demanding imagination, sensitivity to detail, and expert skills.
System design has three objectives. First, the system designer is responsible for considering alternative technology configurations. Second, designers are responsible for the management and control of the technical realization of system. Detailed programming specifications, coding of data, documentation, testing, and training are all the responsibility of the design staff. Third, the system designer details the system specifications that will deliver the functions identified during systems analysis.
PROGRAMMING : The process of translating design specification into software for the computer constitutes a smaller portion of the system development cycle than design and perhaps the testing activities.
TESTING : Exhaustive and thorough testing must be conducted to ascertain whether the system produces the right results. Test data must be carefully prepared, results reviewed, and corrections made in the system. Unit testing, system testing and acceptance testing must be done in sequence
CONVERSION : Conversion is the process of changing from the old system to the new system. It answers the question, "Will the new system work under real conditions?" Four main conversion strategies can be employed: the parallel strategy, the direct cutover strategy, the pilot study strategy, and the phased approach strategy.PRODUCTION & MAINTENANCE: After the new system is installed and conversion is complete, the system is said to be production. During this stage, the system will be reviewed by both users and technical specialists to determine how well it has met its original objectives and to decide whether any revisions or modifications are in order. Changes to a production system to correct errors, meet new requirements, or improve processing efficiency are termed maintenance.

#) Explain about programming languages.

#) Explain about programming languages.
Programming Languages
Ans: A programming language is one which a computer programmer uses to express solution to a given problem so that it can be understood by a computer. There are many similarities between programming languages and speaking (natural) languages. Just as there are many speaking languages, like English, French, Nepali, so too there are many programming languages, like FORTRAN, Pascal, COBOL, Basic, PL/1 and C. Each programming language has its own grammatical (.syntax) rules which must be obeyed in order to write valid programs, just as a natural language has its own rules for forming sentences. And just as we can assign a meaning to an English sentence, say, each valid statement in a programming language has a specific meaning.
Let us suppose that we have written a program in the programming language C or QBASIC. We might think that the computer can understand and execute the statements, which make up the program C or QBASIC. However, this is not so, at least not directly. The program must first be translated into the (only) language which the computer can understand-this is called the machine language. The act of translating is part of a process called compiling. It is important to understand that the computer can only execute instructions, which are written in machine language. Thus no matter what programming language we use, it must first be translated into machine language before the computer can understand it.
Types of Language
1. Machine Language
When computers were first used, machine language was the only language available for writing programs. Machine language varies from one computer to another, but the basic principles are essentially the same. Everything one wishes to express in machine language is done using the binary number system. In order to illustrate the ideas involved, we will use a computer which has the following features:
a) Say 9999 words of memory, then it is numbered as 0 to 9998
b) A set of instructions, in which the computer can be programmed.
The fact is that a single human instruction to the computer is broken down into a series of simple steps. Computer instructions can be roughly classified as:
-instructions which move data from one word of memory to the next;
-instructions which move data between memory and the accumulator (where arithmetic can be done on it);
-instructions for performing the arithmetic operations ADD, SUBTRACT, MULTIPLY and DIVIDE;
-instructions for comparing two quantities;
-instructions for branching from one instruction to another, that is, for changing the normal order of executing instructions one after the other;
-instructions for performing input/output;
2. Assembly and low level languages
Assembly language is usually called a low-level programming language. We usually think of machine language, that is binary instructions, as the lowest-level programming language. Assembly language is a bit higher than machine language. Each computer has its own assembly language and it differs from computer to computer. Assembler translates or converts the program written in assembly language into machine code.
3. High level languages
The problem oriented languages rather than machine oriented languages are HLL. English words are used as instructions. Fortran and Cobol are the earliest and Pascal, PL/1, Basic, C are the popular. HLL are machine independent languages. A program is said to be portable if it can be used on other computers. Program written in HLL are portable

Q. Draw a block diagram of digital computer and describe each component in brief?

# Draw a block diagram of digital computer and describe each component in brief.
Ans: Computer system is an integrated work of Input unit, Processing unit and Output unit. Raw data given by input unit is processed by Central processing unit and the required out(information) is provided by output unit. The components of computer system are as:

Computer system
· Input unit: An input unit takes the input and converts it into binary form so that the computer can understand it. It is formed by input devices e. g keyboard, mouse, light- pen.
· Central Processing Unit : The brain of computer to execute programs and control the operation of other unitsComponents of CPU
§ MU(Register): It is primary storage and temporarily stores incoming data, intermediate data and final result of processing. It also stores instructions for a job
§ ALU: ALU performs mathematical calculation(+, -, X, / ), logical ( <, >, =, <=, >=, <>) operations. The result of logical operation is TRUE or False.
§ CU: The Control Unit controls and guides the interpretation, flow and manipulation of all data and information. CU sends control signals until the required operations are done properly by ALU and memory. It is responsible for timing and queue for data and instruction. CU gives command to transfer data from the input device ® memory ® ALU ® memory ® output device
CPU chip (processor)->MIPS->ALU + MU + CU =CPUOutput unit : The outcome of CPU is in the form of electronic binary signals is converted by Output unit that can be understood by human beings. VDU, printer, plotter etc are the devices for OU.

Explain about assembler and interpreter

Explain about assembler and interpreter
Ans:
Compiler: A program that translates source code into object code is known as compiler. It reads entire codes and converts into machine code, if it finds no mistake in the program. It also makes "exe" file so that the "exe" file executes without source code and its language program. Compiling is done at the end of program development
Interpreter: An interpreter translates high-level instructions into an intermediate form one statement at a time which it then executes. Every time program is executed, the interpreter interprets the code to machine. It is required to test the code at the stages of software development so it guides user.

Explain about computer memory

Explain about computer memory
Ans:Memory is a predefined working place, where data and information are kept for processing and it is cleared after the job is accomplished or as switched off. A bit is an elementary unit of the memory. It is also known as primary or main memory and the data is dump for future reference to secondary memory i.e. hard disk.
We need primary memory for
· Loading operating system
· Any program (application software) has to be loaded into RAM (Primary Memory) for execution
· Data and information is saved into RAM until it is finally saved into permanent memory.
ROM
· Semiconductor chip
· Non-volatile
· Set by manufacturers
· Contain micro programs or control instructions
· Responsible for starting computer
· Cannot be changed or written program
· Permanently attached to board
· PROM (User can reduce lengthy program to micro)
· EPROM (can be erased & reprogrammed)
· EEPROM (can be reprogrammed with special electrical pulses)
RAM
· Semiconductor chip
· Volatile
· Steady electricity supply
· Directly accessed by CPU(50nano sec)
· DRAM (for larger memory capacity, for very short time/refreshed, cheaper, 16 bytes or more is by it, a transistor on-off, a capacitor-storing electric charge)
· SRAM (data is retained till power on, high cost, higher speed as computer DRAM, more capacitors and transistors)
CACHE MEMORY
· between CPU & RAM
· Access time 10 nano sec
· Costlier than RAM
· less capacityto store data & instruction for immediate execution

Monday, June 15, 2009

example programs in C(read before copying)

write the header file by yourself

AP in C to display the information of a person
#include
#include
#include void main()
{
int ward_num=6; // 2 bytes 32767 to -32768
char sex='f'; // 1 byte single character 'f' or 'm'
char name[30]="Laxmi Prasad Devkota"; // string or array of string
float phone=4781698; // 4 bytes containing decimal/exponent
double num_of_cell_in_body=9999999999999999999999999999; //8 bytes
// the basic data types are int,char,float,double
// besides, the data type qualifers are short, long, signed
// and unsigned
// for example short int, long int, unsigned in
clrscr();
printf("\nname:=%s:",name);
printf("\nphone=%.0f",phone);
printf("\nsex=%c",sex);
printf("\nbody cell=%f",num_of_cell_in_body);
printf("\nWard=%d",ward_num);
getch();
}



#include
#include
void main()
{
int first,second,lcm;
/*finding L.C.M.*/
clrscr();
printf("Enter first number:");
scanf("%d",&first);
printf("Enter second number:");
scanf("%d",&second);
lcm=first;
do
{
if(lcm%first==0)
if(lcm%second==0)
break;
lcm++;
}while(1);
printf("\n\nL.C.M.=%d",lcm);
getch();
}

#include
void main()
{
int age[5],temp,pass, i;
printf(“Enter 5 elements:\n”);
for(i=0;i<5;i++) pass="0;pass<4;pass++)" i="0;i<=">age[i+1])
{
temp=age[i];
age[i]=age[i+1];
age[i+1]=temp;
}
}
}
printf(“Sorted list:\n”);
for(i=0;i<5;i++)>
#include
void main()
{
int a,b,choice;
clrscr();
printf("Enter first numbe:");
scanf("%d",&a);
printf("Enter second number:");
scanf("%d",&b);
printf("\n\n\n\nChoose the number\n");
printf("\n1 for add\n2 for subtract\n3 for multiple\n4 for divide\n");
scanf("%d",&choice);
switch (choice)
{
case 1:
printf("Sum=%d",a+b);
break;
case 2:
printf("Difference=%d",a-b);
break;
case 3:
printf("Product=%d",a*b);
break;
case 4:
printf("Quotient=%d",a/b);
break;
};
printf("\n Thank you");
getch();
}






#include
#include
void main()
{
int a,b,choice;
clrscr();
printf("Enter first numbe:");
scanf("%d",&a);
printf("Enter second number:");
scanf("%d",&b);
printf("\n\n\n\nChoose the number\n");
printf("\n1 for add\n2 for subtract\n3 for multiple\n4 for divide\n");
scanf("%d",&choice);
switch (choice)
{
case 1:
printf("Sum=%d",a+b);
break;
case 2:
printf("Difference=%d",a-b);
break;
case 3:
printf("Product=%d",a*b);
break;
case 4:
printf("Quotient=%d",a/b);
break;
};
printf("\n Thank you");
getch();
}
#include
#include
#include
#include
void f1(int a);
int p=0;
void main()
{
int num;
//exit(1);
clrscr();
while(1)
{
printf("Enter only even number");
scanf("%d",&num);
if(num%2==0)
f1(num);
} }

void f1(int x )
{
int static y;
printf("\nthank u you number is %d",x);
y++;
if(y>5)
{
printf("\ntired!");
getch();
exit(1);
}
//clrscr();
}
1. Initialize or store roll, name and two subjects' marks of a student in a structure and display it.
#include
#include
void main()
{
struct mydatatype{
int roll;
char sname[20];
int comp,eng;
};
struct mydatatype student = { 1,"Ram",24,23 };
clrscr();
printf("\nYour information\n\n");
printf("\nRoll %d",student.roll);
printf("\nName %s",student.sname);
printf("\nComputer %d",student.comp);
printf("\nEnglish %d",student.eng);
getch();
}
2. Initialize or store roll, name and two subjects' marks of 3 students in a structure and display it.
#include
#include
void main()
{
int i;
struct mydatatype{
int roll;
char sname[20];
int comp,eng;
};
struct mydatatype student[] = { 1,"Ram",24,23,
2, "Seeta",21,12,
3, "Laxman", 12, 11,
};
clrscr();
printf("\nYour information\n\n");
for(i=0;i<=2;i++) { printf("\nRoll %d",student[i].roll); printf("\nName %s",student[i].sname); printf("\nComputer %d",student[i].comp); printf("\nEnglish %d",student[i].eng); } getch();} 3. Get roll, name and two subjects marks of n students in a structure and display it. #include
#include
void main()
{
int i,n;
struct mydatatype{
int roll;
char sname[20];
int comp,eng;
};
struct mydatatype student[80];
clrscr();
printf("\nHou many students?");
scanf("%d",&n);
for(i=0;i$n;i++) //type < i="0;i$n;i++)//type" i="0;i<4;i++)" roll="i+1;" i="i-1;">
main()
{
int i;
struct exam
{
int prg;
int math;
};
struct exam subjcect;

struct info
{
char sname[20];
int phone;
};
struct info names;

struct details
{
int roll;
struct exam subject;
struct info names;
};
struct details students[4];
clrscr();
for(i=0;i<4;i++) roll="i+1;" i="i-1;">
#include
typedef struct
{
int h,m,s;
}TIME;
TIME calculater(TIME start, TIME stop,int check);
void main()
{
TIME start,stop,sum,diff;
int hh,mm,ss;
clrscr();
printf("Enter start time:\nHour:");
scanf("%d",&hh);
printf("\nMinutes:");
scanf("%d",&mm);
printf("\nSeconds:");
scanf("%d",&ss);
start.h=hh;
start.m=mm;
start.s=ss;
printf("Enter stop time:\nHour:");
scanf("%d",&hh) ;
printf("\nMinutes:");
scanf("%d",&mm);
printf("\nSeconds:");
scanf("%d",&ss);
stop.h=hh;
stop.m=mm;
stop.s=ss;
sum=calculater(start,stop,1);
printf("\nThe sum is\n");
printf("\n%dhh%dmm%dss",sum.h,sum.m,sum.s);
diff=calculater(start,stop,0);
printf("\nThe diff is\n");
printf("\n%dhh%dmm%dss",diff.h,diff.m,diff.s);
getch();
}
TIME calculater(TIME a, TIME b,int check)
{
TIME sum;
int x;
int temp;
if (check==1)
temp=a.h*3600+a.m*60+a.s+b.h*3600+b.m*60+b.s ;// meaning less to add
else
temp=((b.h*3600+b.m*60+b.s)-(a.h*3600+a.m*60+a.s)) ;

sum.s=temp%60;
temp/=60;
sum.m=temp%60;
sum.h=temp/60;
return sum;
}















































// Get roll, name and two subjects marks of n students in a structure and display it.
#include
#include
struct age
{
float y,m,d;
}dob,now,dif;
void main()
{
age cal(age birth, age now);
clrscr();
printf("Enter year,month and date of date of birth:");
scanf("%f",&dob.y);
scanf("%f",&dob.m);
scanf("%f",&dob.d);

printf("Enter year,month,and date of system date");
scanf("%f",&now.y);
scanf("%f",&now.m);
scanf("%f",&now.d);
dif=cal(dob,now);
printf("\nRequired Age:\n:%.0f:",dif.y);
printf(" year %.0f",dif.m);
printf(" month %.0f day",dif.d);
getch();
}
age cal(age x, age y)
{
float temp1,temp2;
temp1=(y.y*365+y.m*60+y.d)-(x.y*365+x.m*60+x.d);
temp2=temp1;
while (temp2>=30)
{ temp2-=30;};
dif.d=temp2;
temp2=temp1/30;
while(temp2>=12)
{temp2-=12;};
dif.m=temp2;
dif.y=temp1/360;
return (dif);
}









/* reorder a one dimensional, integer array from samllest to largest
using pointer notation*/
#include
#include
#include
void reorder(int n, int *x);
void main()
{
int i,n,*x;
clrscr();
printf("How many numbers wil be entered?");
scanf("%d",&n);
x=(int*) malloc(n*sizeof(int));
for(i=0;i$n;++i)//type < i="0;i$n;i++)//type" item="0;item$n-1;++item)//type" i="item+1;i$n;++i)//type" temp="*(x+item);">
#include
#include
void main()
{
FILE *ptr;
int num,i;
int identity,off_name,occu;
char name[10];
clrscr();
printf("How many reocrds?");
scanf("%d",&num);
ptr=fopen("employee.dat","w");
for(i=0;i$num;i++)//type <>
#include
#include
void main()
{
FILE *ptr;
char c;
clrscr();
ptr=fopen("myfile.dat","w");
do
putc(toupper(c=getchar()),ptr);
while(c!='\n');
fclose(ptr);
}



































2} Write a program to read one line text from a data file.
#include
#include
#include
#define NULL 0
void main()
{
FILE *ptr;
char c;
clrscr();
if((ptr=fopen("myfile.dat","r"))==NULL)
printf("File not found.");
else
do
putchar(c=getc(ptr));
while(c!='\n');
fclose(ptr);
getch();
}
































3} Write a program to store n names in a data file.
#include
#include
#include
void main()
{
FILE *ptr;
int num,i;
char name[10];
clrscr();
printf("How many reocrds?");
scanf("%d",&num);
ptr=fopen("myfile.dat","w");
for(i=0;i$num;i++)//type <>
#include
#include
#include
#define NULL 0
# define spac " "
void main()
{
FILE *ptr;
char c;
int i=0,j;
clrscr();
if((ptr=fopen("myfile.dat","r"))==NULL)
printf("File not found.");
else
do
{
c=getc(ptr);
if(c==',')
putchar('\n');
else
putchar(c);
if(c==' ')
j++;
i++;
}while(feof(ptr)==0);
fclose(ptr);
getch();






















5} }Write a program to append some names in an existing data file.
#include
#include
#include
#include
void main()
{
FILE *fptr;
char name[10],c;
clrscr();
fptr=fopen("myfile.txt","a");
do
{
printf("Name:");
scanf("%s",name);
fprintf(fptr,name);
fprintf(fptr,",");
printf("Press \"y\" to continue\n");
c=getche();
}while(toupper(c)=='\Y');
fclose(fptr);
}





























6} Write a program to create/append/disp data of a data file. Also use structure.
#include
#include
#include
# define null 0
struct info{
int roll;
char name[20];
char of_name[20];
char oc_name[20];

};
FILE *ptr;
void dispmenu();
void create(void);
void add(void);
info dispdata(void);
void main()
{
int choice;
info student;
repeat:
dispmenu();
scanf("%d",&choice);
if(choice<1>4)
goto repeat;
else if (choice==1)
create();
else if (choice==2)
add();
else if (choice==3)
{
clrscr();
if((ptr=fopen("myfile.dat","r"))==null)
printf("File not found.");
else
{
choice=0;
do
{
student=dispdata();
choice++;
printf("%d.%d",choice,student.roll);
printf("%s\n",student.name);
}while(feof(ptr)==0);
getch();
fclose(ptr);
}
}
else if(choice==4)
exit(1);
goto repeat;
}
void dispmenu()
{
clrscr();
printf("\n1.Create New File.\n2.Add(append)");
printf("\n3.Display\n4.Exit\nChoose 1 to 4");
}
void create()
{
info student;
ptr=fopen("myfile.dat","w");
clrscr();
printf("Roll:");
scanf("%d",&student.roll);
printf("name");
scanf("%s",student.name);
?????????????????
fprintf(ptr,"%d%s\n",student.roll,student.name);
fclose(ptr);
}
void add()
{
info student;
clrscr();
ptr=fopen("myfile.dat","a");
printf("Roll:");
scanf("%d",&student.roll);
printf("name:");
scanf("%s",student.name);
fprintf(ptr,"%d%s\n",student.roll,student.name);
fclose(ptr);
}
info dispdata()
{
info student;
{
fscanf(ptr,"%d",&student.roll);
fscanf(ptr,"%[^\n]",student.name);
return(student);
}
}









7} Get a phrase and print in alphabetical order.
#include
#include
#include
#define eol '\n'
void main()
{
char text[80],abc;
int i,j,k;
clrscr();
printf("\nEnter the text to display in alphabetical order\n");
for(i=0;(text[i]=getchar())!=eol;++i)
;
k=i-1;
printf("\n\n\n");
for(i=0;i$k;i++)//type < j="0;j$k;j++)//type" i="j;i" abc="text[j];">=0;--i)
putchar(text[i]);
getch();

}
Examples
#include
main()
{
FILE *buffer;
char text[20];
clrscr();
printf("Enter you name to store in data file: ");
scanf("%s",text);
buffer=fopen("txt.dat","w");
fprintf(buffer,text);
fclose(buffer);
/*see the text from dos */
}
/*---------------------------------------------------------------------------*/#include
struct record
{
char name[20];
char address[20];
} student[5];

main()
{
FILE *buffer;
char fname[20];
int num,i;
clrscr();
printf("Enter the file name: ");
scanf("%s",fname);
buffer=fopen(fname,"a");
printf("How many students? ");
scanf("%d",&num);
for(i=1;i<=num;i++) { printf("Name: "); scanf("%s",student[i].name); printf("Address: "); scanf("%s",student[i].address); fprintf(buffer,student[i].name); fprintf(buffer,student[i].address); fprintf(buffer,"\n"); } fclose(buffer); } #include
#define finished 0
main()
{
FILE *buffer;
char filename[10];
char text[20];
clrscr();
printf("Enter existing data file name to read: ");
scanf("%s",filename);
if((buffer=fopen(filename,"r"))==finished)
printf("Wrong file name! ");
else
{
fscanf(buffer,"%s",text);
printf("%s",text);
}
getch();
fclose(buffer);
}































/*********PROJECT WORK**************/
/*Write a program to create/append/disp data of a data file.
Also use structure.*/
#include
#include
#include
#include
# define null 0
struct info{
int roll;
char name[20];
}student;
FILE *ptr,*ptr1;
void dispmenu();
void create(void);
void add(void);
void dispdata(void);
void disp_one(void);
void modify(void);
void del_one(void);
void del_all(void);
void main()
{
int choice;
repeat:
dispmenu();
scanf("%d",&choice);
if(choice<1>8)
goto repeat;
else if(choice==1)
create();
else if(choice==2)
add();
else if(choice==3)
dispdata();
else if(choice==4)
disp_one();
else if(choice==5)
modify();
else if(choice==6)
del_one();
else if(choice==7)
del_all();
else if(choice==8)
exit(1);
goto repeat;
}
void create()
{
ptr=fopen("myfile.dat","w");
clrscr();
printf("Roll:");
scanf("%d",&student.roll);
printf("name");
scanf("%s",student.name);
fprintf(ptr,"%d%s\n",student.roll,student.name);
fclose(ptr);
}
void add()
{
clrscr();
ptr=fopen("myfile.dat","a");
printf("Roll:");
scanf("%d",&student.roll);
printf("name:");
scanf("%s",student.name);
fprintf(ptr,"%d%s\n",student.roll,student.name);
fclose(ptr);
}
void dispdata()
{
clrscr();
if((ptr=fopen("myfile.dat","r"))==null)
printf("File not found.");
else
{
while(1)
{
fscanf(ptr,"%d",&student.roll);
fscanf(ptr,"%[^\n]",student.name);
if(student.roll==null)
break;
printf("%d ",student.roll);
printf("%s\n",student.name);
student.roll=null;
}
getch();
fclose(ptr);
}
}
void disp_one()
{
int roll;
clrscr();
if((ptr=fopen("myfile.dat","r"))==null)
printf("File not found.");
else
{
printf("Enter roll:");
scanf("%d",&roll);
do
{
fscanf(ptr,"%d",&student.roll);
fscanf(ptr,"%[^\n]",student.name);
if(roll==student.roll)
{
printf("%d ",student.roll);
printf("%s\n",student.name);
break;
}
}while(feof(ptr)==0);
getch();
fclose(ptr);
}
}
void modify()
{
int roll;char name[20];
clrscr();
if((ptr=fopen("myfile.dat","r"))==null)
printf("File not found.");
else
{
printf("Enter roll:");
scanf("%d",&roll);
printf("Enter name:");
scanf("%s",name);
ptr1=fopen("test","w");
do
{
fscanf(ptr,"%d",&student.roll);
fscanf(ptr,"%[^\n]",student.name);
if(roll==student.roll)
{
student.roll=roll;
strcpy(student.name,name);
}
fprintf(ptr1,"%d%s\n",student.roll,student.name);
}while(feof(ptr)==0);
getch();
fclose(ptr);
fclose(ptr1);
remove("myfile.dat");
rename("test","myfile.dat");
}
}
void del_one()
{
int roll;char name[20];
clrscr();
if((ptr=fopen("myfile.dat","r"))==null)
printf("File not found.");
else
{
printf("Enter roll:");
scanf("%d",&roll);
ptr1=fopen("test","w");
while(1)
{
fscanf(ptr,"%d",&student.roll);
fscanf(ptr,"%[^\n]",student.name);
if(student.roll==null)
break;
else if(student.roll==roll)
;
else
{
fprintf(ptr1,"%d%s\n",student.roll,student.name);
student.roll=0;
}
}
fclose(ptr);
fclose(ptr1);
remove("myfile.dat");
rename("test","myfile.dat");
}
}

void del_all()
{
remove("myfile.dat");
}
void dispmenu()
{
clrscr();
printf("\n1.Create New File.\n2.Add more(append)");
printf("\n3.Display all\n4.Disp particular");
printf("\n5.Modify one\n6.Delete one");
printf("\n7.Delete all\n8.Exit\nChoose 1 to 8 only");
}

Saturday, June 13, 2009

Yarsagumba Yarchagumba cordyceps sinesis Himalayan Herbal Viagra


Yarshagumba: the caterpillar fungus


Nicknamed the "Himalayan Viagra", yarshagumba (Cordyceps sinensis) is a rare species of parasitic fungus from the highlands of Nepal, Tibet and Bhutan.







Yarshagumba
Cordyceps sinensis: (Yarshagumba) Yarshagumba
Venacular name: Yarsagumba, Jibanbuti
Family: Clavicipitaceae
Distribution: Sub-alpine to alpine region of Nepal
Habitat: Meadows

Yarsagumba with its Latin name cordyceps sinesis literally means summer plant and winter insect in Tibetan. Before the rainy season begins, spores of the cordyceps mushroom settle on the heads of caterpillars’ that lives underground. The fungus gets so much into the body of the caterpillars’ that it grows out through its head and drains all the energy from the insect and ultimately it dies.

Yarsagumba, Yarshagumba or Yarchagumba is a rare and unique herb that grows in the meadows above 3,500 meters (11,483 feet) in the Himalayan region of Nepal. There are various types of famous medicinal plants found in Nepal but the popularity of yarsagumba is simply overwhelming. For the last couple of years, the trade of yarsagumba is increasing and it has been regarded as an expensive life saving tonic. Headache, toothache or any other disease - yarsagumba is the remedy. And not only that, it is also believed to be a cure for sexual impotency – a Himalayan Herbal Viagra.
fig: people searching yarshagmba

Every year during May and June, thousands of villagers from remote areas risking their own lives head for high mountains to collect yarsagumba. It is estimated that one villager can earn up to Rs. 2,500 approximately to $35 a day by collecting yarsagumba which is beyond the monthly salary of many Nepalese households. Dolpa – a remote district in western Nepal with high steep valleys and dry climate is one of the foremost areas for collecting yarsagumba. Almost 50% of the annual supply of yarsagumba comes from Dolpa alone. Here, not only the adults but school goers also take unofficial holidays in search of the gold rush.

The Himalayan region of Nepal is famous for different types of medicinal plants. Yarshagumba is one of them. The literal meaning of Yarshagumba is summer plants, winter insect. Yarshagumba is currently very popular due to its use as aphrodisiac (sex stimulant) and tonic. Hence its collection and trade is increasing. Considering its importance, the Department of Plant Resources included a programme named as "Study of Yarshagumba in the natural habitat" in its overall programmes. Yarshgumba in Dolpa district. They covered the natural extent of distribution between 2800-4500 meters.

Details of field based information:
Occurrence : 2800-4500 meters
Availability : 2500 plants per hectare
Soil quality : pH 7-7.5
Associated plants : Rhododendron anthopogon, Anemone sp., Anaphalis sp.,Carese sp., etc.
Collection time: April/May – June/July
Germination time : April – June/July
Weight : 0.3 to 0.5 gm. per plant
Resercah need: The Department is attempting to culture fungus from spores on the Yarshagumba


Yarshagumba trade
Yarsagumba collection in Bajhang-Nepal Himalaya
FUGs are now responsible for collecting entry charges from harvesters (NRs. 100 per collector) and a further conservation charge (NRs. 5,000 per kg) is levied. In the first year alone, the groups collected over NR800,000 (US$12,500). Following initial difficulties in collecting the charges, the FUGs set up four teams of younger group members to guard the entry points to the harvesting areas and enforce the fees. The fee income has been used to develop a micro-hydropower plant, benefiting all three FUGs.
Selling Yarshagumba tonic without any side effects
Yarshagumba (sex tonic) is currently very popular due to its use as aphrodisiac (sex stimulant) and tonic.

Known benefits and it is also use for

1) Asthma, allergic rhinitis* -poor renal function, renal injuries by chemicals** -chronic bronchitis, coughing
2)poor resistance of respiratory tract, catching flu easily -regulating blood pressure (high or low blood pressure)
3)Anti-aging, weakness: - the declining of sex drive -lowering raised blood lipid levels, strengthening the body's immunity
4)Poor function of lungs & kidneys, irregular menstruation
5)Ever heard anything about natural healthy warrior!

We mean you can fight with tiredness stand youth with the harmony of nature.

The New York journal of medicine reported that cordyceps has properties similar to ginseng, being used to strengthen the body after exhaustion or long term illness. It has traditionally been used for impotence, backache, to increase sperm production and to increase blood production. It is used specifically for excess tiredness, chronic cough and asthma, impotence, debility, anemia, to build the bone marrow and reduce excess phlegm.