Basic algebra formulas that you can revise anytime and anywhere

FORMULAS FOR BEGINNER (a+b) ^2= a^2+b^2+2ab (a+b) ^2= (a-b) ^2+4ab (a-b) ^2= a^2+b^2-2ab (a-b) ^2= (a+b) ^2-4ab a^2+b^2= (a+b) ^2-2ab a^2+b^2= (a-b) ^2+ 2ab a^2-b^2= (a+b) (a-b) (a+b+c) ^2= a^2+b^2+c^2+2(ab+bc+ac) (a-b-c) ^2= a^2+b^2+c^2-2(ab-bc+ac) (a+b) ^3= a^3+b^3+3ab(a+b) (a-b) ^3= a^3-b^3+3ab(a-b) a^3+b^3= (a+b) (a^2-ab+b^2) a^3-b^3= (a-b) (a^2+ab+b^2) a^4-b^4= (a^2-b^2) (a^2+b^2) = (a^2+b^2) (a+b) (a-b) a^5+b^5= (a+b) (a^4-a^3b+a^2b^2-ab^3+b^4) a^5-b^5= (a-b) (a^4+a^3b+a^2b^2+ab^3+b^4)

File Operations and Functions





File Pointers

It is not enough to just display the data on the screen. We need to save it because memory is volatile and its contents would be lost once program terminated, so if we need some data again there are two ways one is retype via keyboard to assign it to particular variable, and other is regenerate it via pro-grammatically both options are tedious. At such time it becomes necessary to store the data in a manner that can be later retrieved and displayed either in part or in whole. This medium is usually a ''file'' on the disk.


Introduction to file

Until now we have been using the functions such as scanf,printf, getch, putch etc to read and write data on the variable and arrays for storing data inside the programs. But this approach poses the following programs.
1. The data is lost when program terminated or variable goes out of scope.
2. Difficulty to use large volume of data.

We can overcome these problems by storing data on secondary devices such as Hard Disk. The data is storage on the devices using the concept of ''file''.

A file is collection of related records, a record is composed of several fields and field is a group of character.

The most straightforward use of files is via a file pointer.

  FILE *fp;
fp is a pointer to a file.

The type FILE, is not a basic type, instead it is defined in the header file stdio.h , this file must be included in your program.


File Operations

1. Create a new file.
2. Open an existing file
3. Read from file
4. Write to a file
5. Moving a specific location in a file(Seeking)
6. Closing File


Opening a File

fp = fopen(filename, mode);

The filename and mode are both strings.

Here modes can be
"r" read
"w" write, overwrite file if it exists
"a" write, but append instead of overwrite
"r+" read & write, do not destroy file if it exists
"w+" read & write, but overwrite file if it exists
"a+" read & write, but append instead of overwrite
"b" may be appended to any of the above to force the file to be opened in binary mode rather than text mode.

Eg.
FILE *fp;
fp=fopen(''input.txt'',''r'');
//Opens inputs.txt file in read mode
fclose(fp); //close file

Sequential file access is performed with the following library functions.

1. fopen() - Create a new file
2. fclose() - Close file
3. getc() - Read character from file
4. putc() - Write character to a file
5. getw() - Read Integer from file
6. putw() - Write Integer to a file
7. fprintf() - Write set of data values
8. fscanf() - Read set of data values


These are the Concept of C programming . We'll be glad if you share your valuable information with us regarding this topic, then it will be a golden opportunity for all of us to improve ourselves and know more. Comment below!!

Comments

Popular posts from this blog

Are you willing to relocate or travel(HR QUESTION)

How to answer " why do you want to work at our company? "(HR QUESTION)