Skip to main content

Posts

Definition of Computer Fundamental

 Computer is derived from the Latin word computare which mean calculate. Computer can be defined as an electronic digital and automatic machine. takes  input  from the user, process it, stores it if necessary and gives output in desired form.  Computer is the most powerful device the human being has ever invented. It brought enormous effects in our daily life and changes in the world. Features of Computer 1. High speed, decreasing size and cost 2. Accuracy and reliability 3. Vast storage capacity 4. Automatic 5. Electronic 6. Non – intelligent Advantages 1. Computer is faster then human 2. 100% accurate and reliable 3. Can perform various type of  work 4. Very useful for repeated job. 5. Complicated things are easy to show and simulate. Disadvantages 1. Danger of  electric shock and other physical Damages. 2. Failure of device and programs can produce unreliable information. 3. Increases dependency on them. 4. Simple mistake can...

Explanation of Graphics in C programming

   The header file graphics.h should be included to use graphics related built in functions. Again, the variable gDriver is an integer variable that specifies graphics driver to be used. Device drivers are small programs which talk directly to the hardware. Graphics drivers are a subset of device drivers and are applicable only in the graphics mode. The initialization of this variable to DETECT is to set another variable gMode to the highest resolution available for the detected driver.  The value of this variable gDriver may be another than DETECT (e.g. 1 for CGA, 9 for VGA.). The variable gMode is an integer that specifies initial graphics mode.       The built in function initgraph() is for graphics initialization. The syntax for this is as   initgraph(&graphics_driver, &graphics_mode, path_to_driver);   path_to_driver specifies the directory path where initgraph() looks for graphics drivers ( .BGI files). Thi...

Graphics

Computer graphics is one of the most powerful and interesting aspects of computers. There is a lot that we can do in graphics apart from drawing figures of various shapes. All video games, animation, multimedia predominantly works with computer graphics. To work with graphics, C has various library functions. Some of built in functions which are defined within header file graphics.h are illustrated in this chapter. Let us see one example which demonstrates graphics initialization and some built in functions related to graphics. #include<graphics.h> void main() { int gDriver=DETECT,gMode; int polyArray[]={200,100,250,150,300,200,350,200,300,150,200,100}; initgraph(&gDriver,&gMode,"c:\\tc\\bgi"); setcolor(GREEN); line(200,100,300,250); /*line from (200,100) to (300,250) */ circle(300,300,50); /*circle at center (300,300) having radius 50 */ ellipse(150,200,0,360,100,50);           /* ellipse at cen...

Difference between Binary mode and Text Mode in C programming

There are mainly three difference between binary and text mode. They are as follow.               i.       In text mode, a special character EOF whose ASCII value is 26 is inserted after the last character in the file to mark the end of file. But, there is no such special character present in the binary mode. The binary mode files keep track of the end of file from the number of characters present in the directory entry of the file.             ii.       In text mode of file, text and numbers are stored as one character per byte. For example, the number 1234 occupies two bytes in memory but it occupies 4 bytes (one byte per character) in the file. But, in binary mode, the number occupies the number of bytes as it occupies in the memory. Thus,  the above number occupies two bytes in file also in the case o...

Binary Mode of Data Files in C Programming

     In Binary mode of data file, the opening mode of text mode file is appended by a character ‘b’ i.e. “r” is replace by “rb” “w” is replace by “wb” “a“ is replace by “ab” “r+” is replace by “r+b” “w+” is replace by “w+b” “a+” is replaced by “a+b” The default mode is text mode. Thus when simple “r” is written as mode of opening, this is assumed as text mode. We can write “rt” in place of “r” and so on in the case of text of file. The syntax for all above mode in the case of binary mode is similar to the previous one i.e. text mode like this fptr=fopen(“data.txt”,”rb”); 

End Of File (EOF) in Programming

               The EOF is a special character, whose ASCII value is 26, which indicates the end of a file in text mode of file. While writing data to a file, this character is inserted automatically after the last character in the file to mark the end of file. If this character is detected at any point in the file, the read function would return the EOF signal to the program indicating the last point of file. An attempt to read after EOF might either cause the program to terminate with an error or result in an infinite loop situation. Thus, the last point of file is detected using EOF while reading data from file. Without this mark, we can not detect last character at the file such that it is difficult to find up to what time the character is to be read while reading data from the file.

Some Graphics Mode Graphics Functions in C programming

putpixel( ): Plot a point with specified color. Its syntax is Putpixel (int x, int y, int color), getpixel( ): gets color of specified pixel. Its syntax is integer_variable = getpixel (int x, int y); setcolor( ) : It changes current drawing/ foreground color. Its syntax is setcolor (int color); setbkcolor( ): It changes the background color. Its syntax is setbkcolor(int color); line( ): The line ( ) function can draw a line. The syntax of line( ) function is: line(x1, y1, x2, y2), where x1, y1, x2, y2 are integer type and they represent the coordinate (x1, y1) and (x2, y2). The above command draws a line joining two points with coordinates (x1, y1) and (x2, y2). lineral( ): the function lineral (x, y) draws a line joining the current cursor position and a point at a distance of x in the horizontal and y in vertical direction. Note that x and y both are integer type. lineto( ): The function lineto (x, y) draws a line joining the current cursor position ...