caite.info Biography ADVANCED C PROGRAMMING BY EXAMPLE PDF

Advanced c programming by example pdf

Thursday, April 4, 2019 admin Comments(0)

Calling conventions (examples: MIPS, Intel). • Calling assembly code from C. • Calling C from assembly code. • Understanding C's call by value mechanism. Why Advanced C? “Our”. ▻ we need experienced C programmers . Example. The clauses P ∨ ¬Q ∨ R, Q ∨ ¬R can be coded by the file c first, simple. Title: Advanced C Programming By Example Author: John W http://www. caite.info Title: Advanced C.


Author: LARISSA SPALTER
Language: English, Spanish, Japanese
Country: United States
Genre: Science & Research
Pages: 409
Published (Last): 05.07.2016
ISBN: 281-7-34999-687-4
ePub File Size: 23.68 MB
PDF File Size: 11.13 MB
Distribution: Free* [*Regsitration Required]
Downloads: 21274
Uploaded by: LAQUANDA

C. C C. Advanced C. Peter D. Hipson. A Division of Prentice Hall Computer Publishing. W. rd Screen reproductions in this book were created by means of the program Collage Plus, from Inner .. An Example of Pointers, Indirection. Lecture 6: C programming: Advanced . C is a procedural language .. Example struct list a, b, c; caite.info = 1; caite.info = 2; caite.info = 3; caite.info = caite.info = caite.info ADVANCED C PROGRAMMING BY EXAMPLE PDF - In this site isn`t the same as a solution manual you buy in a book store or download off the web. Our.

The scope of the static variables is local to the block in which the variables are defined. It is necessary to use a C definition of the CPU programming model, this allows the registers to be initialised with the correct values before the interrupt is generated. Compile Program. Write a program to check whether the given number is a prime. A monochrome monitor, for example, can't display colors no matter how powerful the video adapter.

What is pass by value in functions? Pass by Value: In this method, the value of each of the actual arguments in the calling function is copied into corresponding formal arguments of the called function. In pass by value, the changes made to formal arguments in the called function have no effect on the values of actual arguments in the calling function.

In the main function, value of variables m, n are not changed though they are passed to function 'swap'. Swap function has a copy of m, n and hence it can not manipulate the actual value of arguments passed to it.

Out of the functions fgets and gets , which one is safer to use and why? Out of functions fgets and gets , fgets is safer to use. There is no limit for the input string. The string can be too long and may lead to buffer overflow.

The function fgets takes three arguments. First argument: Second argument: Third argument: Thereby it avoids overflow of input buffer. Thus fgets is preferable to gets. What are the differences between getchar and scanf functions for reading strings? Differences between getchar and scanf functions for reading strings: What is the difference between the functions strdup and strcpy?

In strcpy function both source and destination strings are passed as arguments. User should make sure that destination has enough space to accommodate the string to be copied. If successful, strcpy subroutine returns the address of the copied string.

Otherwise, a null pointer is returned. Example Program: This is because string 'myname' is declared to be of size 10 characters only. In the above program, string "nodalo" is copied in myname and is printed on output screen. Function will copy the contents of string to certain memory location and returns the address to that location. Function returns address of the memory location where the string has been copied. In case free space could not be created then it returns a null pointer.

Program to illustrate strdup. String myname consists of "interviewmantra. Contents of myname are copied in a memory address and memory is assigned to name. At the end of the program, memory can be freed using free name ; What is a pointer in C?

A pointer is a special variable in C language meant just to store address of any other variable or function. It follows a special arithmetic called as pointer arithmetic. A pointer is declared as: A pointer to an integer with name ap was declared.

The pointer ap is now said to point to a. This operator gives the value at the address pointed by the pointer. That is because ap points to a. Pointer arithmetic is different from ordinary arithmetic. Here ap is pointing to an integer variable hence ap is incremented by 2 or 4 bytes depending upon the compiler.

What are the advantages of using pointers? Pointers are special variables which store address of some other variables. Pointers allow us to pass values to functions using call by reference. This is useful when large sized arrays are passed as arguments to functions. A function can return more than one value by using call by reference.

Dynamic allocation of memory is possible with the help of pointers. We can resize data structures. For instance, if an array's memory is fixed, it cannot be resized. But in case of an array whose memory is created out of malloc can be resized.

Pointers point to physical memory and allow quicker access to data. What is the equivalent pointer expression for referring an element a[i][j][k][l], in a four dimensional array? Consider a multidimensional array a[w][x][y][z]. Example program to illustrate pointer denotation of multi-dimensional arrays. This output may differ from computer to computer as the address locations are not same for every computer.

Declare an array of three function pointers where each function receives two integers and returns float. Here 'fn[3]' is an array of function pointers. Each element of the array can store the address of function 'float add int, int '. Explain the variable assignment in the declaration Ans: Each function has two arguments which in turn are pointers to character type variable.

Example program to explain function pointers. In this program p[10] is an array of function pointers. First five elements of p[10] point to the function: They return pointer to an integer and accept pointer to char as arguments. Function average: Function sum: Here a[4] is an array which holds the address of strings. Strings are character arrays themselves.

Memory required to store an address is 4 bits. Explain each statement.

A variable name can not be incremented or decremented. Usually, name of an array points to its base address. Write a program to find factorial of the given number.

A function is called 'recursive' if a statement within the body of a function calls the same function. Itis also called 'circular definition'. Recursion is thus a process of defining something in terms of itself. To calculate the factorial value using recursion. Otherwise the program enters into an infinite loop. Write a program to check whether the given number is even or odd. Enter a: Example 1: If entered number is an odd number. Write a program to swap two numbers using a temporary variable.

Swapping interchanges the values of two given variables. Enter the values of a and b: Write a program to swap two numbers without using a temporary variable. Enter values of a and b: Write a program to swap two numbers using bitwise operators.

Write a program to find the greatest of three numbers.

Enter a,b,c: Write a program to find the greatest among ten numbers. Enter ten values: Entered values are 2, 53, 65, 3, 88, 8, 14, 5, 77, 64 They are stored in an array of size Below loop is executed until end of the array 'a[]';. If any value greater than the value of 'greatest' is encountered, it would be replaced by a[i].

After completion of 'for' loop, the value of variable 'greatest' holds the greatest number in the array. In this case 88 is the greatest of all the numbers. Write a program to check whether the given number is a prime. A prime number is a natural number that has only one and itself as factors. Enter any number n: Write a program to check whether the given number is a palindromic number. If a number, which when read in both forward and backward way is same, then such a number is called a palindrome number.

Subscribe to free updates via email. Thus the given number is a palindrome number. Write a program to check whether the given string is a palindrome. Palindrome is a string, which when read in both forward and backward way is same. Enter a string: To check if a string is a palindrome or not, a string needs to be compared with the reverse of itself.

Consider a palindrome string: If any one of the above condition fails, flag is set to true 1 , which implies that the string is not a palindrome. By default, the value of flag is false 0. Hence, if all the conditions are satisfied, the string is a palindrome. Write a program to generate the Fibonacci series.

Fibonacci series: Any number in the series is obtained by adding the previous two numbers of the series. Let f n be n'th term. The fibonacci series is as follows 3 21 34 Explanation: The first two elements are initialized to 0, 1 respectively. Other elements in the series are generated by looping and adding previous two numbes. These numbers are stored in an array and ten elements of the series are printed as output.

Write a program to compare two strings without using strcmp function.

Advanced C Programming Notes | Bhuhsan Vardhekar - caite.info

Case 2: Strings to be compared are sent as arguments to cmpstr. Each character in string1 is compared to its corresponding character in string2.

Once the loop encounters a differing character in the strings, it would return the ascii difference of the differing characters and exit. Write a program to concatenate two strings without using strcat function. Before concatenation: In strct function, using a for loop, all the characters of string 'c2' are copied at the end of c1. Write a program to display the multiplication table of a given number.

Enter any Number: We need to multiply the given number i. All above questions and answer are selected from www. Advanced Features and Interfacing Miscellaneous and advanced features: Graphics in C: What is the purpose of main function?

In C, program execution starts from the main function. Every C program must contain a main function. The main function may contain any number of statements. These statements are executed sequentially in the order which they are written. The main function can in-turn call other functions. When main calls a function, it passes the execution control to that function. The function returns control to main when a return statement is executed or when end of function is reached.

In C, the function prototype of the 'main' is one of the following: Welcome to the world of C 2.

By advanced example programming pdf c

Explain command line arguments of main function? In C, we can supply arguments to 'main' function. The arguments that we pass to main at command prompt are called command line arguments. These arguments are supplied at the time of invoking the program. The main function can take arguments as: It represents the number of arguments in the command line. The second argument argv is known as 'argument vector'.

It is an array of char type pointers that points to the command line arguments. Size of this array will be equal to the value of argc. Following are the arguments entered in the command line C: What are the differences between malloc and calloc?

Allocation of memory at the time of execution is called dynamic memory allocation. It is done using the standard library functions malloc and calloc. It is defined in "stdlib. It takes one argument, viz. It needs two arguments viz. Differences between malloc and calloc are: Number of arguments differ. By default, memory allocated by malloc contains garbage values. Whereas memory allocated by calloc contains all zeros.

How to use realloc to dynamically increase size of an already allocated array? This function is used to increase or decrease the size of any dynamic memory which is allocated using malloc or calloc functions. The second argument 'newsize' is the size in bytes, of a new memory region to be allocated by realloc. This value can be larger or smaller than the previously allocated memory. The realloc function adjusts the old memory region if newsize is smaller than the size of old memory.

If the newsize is larger than the existing memory size, it increases the size by copying the contents of old memory region to new memory region. The function then deallocates the old memory region. In this case, dynamically allocated array can be used so that it is possible allocate the exact amount of memory using realloc function. Write a program to delete a specified line from a text file.

Example advanced c programming pdf by

In this program, user is asked for a filename he needs to change. User is also asked for the line number that is to be deleted. The filename is stored in 'filename'. The file is opened and all the data is transferred to another file except that one line the user specifies to delete. Program to delete a specific line. Enter file name: I am fine hope the same Enter line number of the line to be deleted: In this program, user is asked for a filename that needs to be modified.

Entered file name is stored in a char array 'filename'. This file is opened in read mode using file pointer 'fp1'. Character 'c' is used to read characters from the file and print them to the output. User is asked for the line number in the file to be deleted. The file pointer is rewinded back and all the lines of the file except for the line to be deleted are copied into another file "copy. Now "copy.

The original file is opened in read mode and the modified contents of the file are displayed on the screen. Write a program to replace a specified line in a text file.

Program to replace a specified line in a text file. In this program, the user is asked to type the name of the file. The File by name entered by user is opened in read mode. The line number of the line to be replaced is asked as input. Next the data to be replaced is asked. A new file is opened in write mode named "copy. Now the contents of original file are transferred into new file and the line to be modified is deleted. New data is stored in its place and remaining lines of the original file are Prepared by: Pointers are special variables which store address of some other variables.

Pointers allow us to pass values to functions using call by reference. This is useful when large sized arrays are passed as arguments to functions. A function can return more than one value by using call by reference. Dynamic allocation of memory is possible with the help of pointers. We can resize data structures. For instance, if an array's memory is fixed, it cannot be resized. But in case of an array whose memory is created out of malloc can be resized.

Pointers point to physical memory and allow quicker access to data. What is the equivalent pointer expression for referring an element a[i][j][k][l], in a four dimensional array? Consider a multidimensional array a[w][x][y][z]. Example program to illustrate pointer denotation of multi-dimensional arrays. This output may differ from computer to computer as the address locations are not same for every computer. Declare an array of three function pointers where each function receives two integers and returns float.

Here 'fn[3]' is an array of function pointers. Each element of the array can store the address of function 'float add int, int '. Explain the variable assignment in the declaration Ans: Each function has two arguments which in turn are pointers to character type variable.

Example program to explain function pointers. In this program p[10] is an array of function pointers. First five elements of p[10] point to the function: They return pointer to an integer and accept pointer to char as arguments. Function average: Function sum: Here a[4] is an array which holds the address of strings. Strings are character arrays themselves. Memory required to store an address is 4 bits. Explain each statement. A variable name can not be incremented or decremented.

Usually, name of an array points to its base address. Write a program to find factorial of the given number. A function is called 'recursive' if a statement within the body of a function calls the same function. Itis also called 'circular definition'. Recursion is thus a process of defining something in terms of itself.

To calculate the factorial value using recursion. Otherwise the program enters into an infinite loop. Write a program to check whether the given number is even or odd. Enter a: Example 1: If entered number is an odd number. Write a program to swap two numbers using a temporary variable. Swapping interchanges the values of two given variables.

Enter the values of a and b: Write a program to swap two numbers without using a temporary variable. Enter values of a and b: Write a program to swap two numbers using bitwise operators. Write a program to find the greatest of three numbers. Enter a,b,c: Write a program to find the greatest among ten numbers.

Enter ten values: Entered values are 2, 53, 65, 3, 88, 8, 14, 5, 77, 64 They are stored in an array of size Below loop is executed until end of the array 'a[]';. If any value greater than the value of 'greatest' is encountered, it would be replaced by a[i]. After completion of 'for' loop, the value of variable 'greatest' holds the greatest number in the array.

In this case 88 is the greatest of all the numbers. Write a program to check whether the given number is a prime. A prime number is a natural number that has only one and itself as factors. Enter any number n: Write a program to check whether the given number is a palindromic number. If a number, which when read in both forward and backward way is same, then such a number is called a palindrome number.

Subscribe to free updates via email. Thus the given number is a palindrome number. Write a program to check whether the given string is a palindrome. Palindrome is a string, which when read in both forward and backward way is same. Enter a string: To check if a string is a palindrome or not, a string needs to be compared with the reverse of itself.

Consider a palindrome string: If any one of the above condition fails, flag is set to true 1 , which implies that the string is not a palindrome.

By default, the value of flag is false 0. Hence, if all the conditions are satisfied, the string is a palindrome. Write a program to generate the Fibonacci series. Fibonacci series: Any number in the series is obtained by adding the previous two numbers of the series. Let f n be n'th term. The fibonacci series is as follows 3 21 34 Explanation: The first two elements are initialized to 0, 1 respectively. Other elements in the series are generated by looping and adding previous two numbes.

These numbers are stored in an array and ten elements of the series are printed as output. Write a program to compare two strings without using strcmp function. Case 2: Strings to be compared are sent as arguments to cmpstr. Each character in string1 is compared to its corresponding character in string2.

Once the loop encounters a differing character in the strings, it would return the ascii difference of the differing characters and exit. Write a program to concatenate two strings without using strcat function.

Before concatenation: In strct function, using a for loop, all the characters of string 'c2' are copied at the end of c1. Write a program to display the multiplication table of a given number. Enter any Number: We need to multiply the given number i.

All above questions and answer are selected from www. Advanced Features and Interfacing Miscellaneous and advanced features: Graphics in C: What is the purpose of main function? In C, program execution starts from the main function. Every C program must contain a main function. The main function may contain any number of statements. These statements are executed sequentially in the order which they are written. The main function can in-turn call other functions.

When main calls a function, it passes the execution control to that function. The function returns control to main when a return statement is executed or when end of function is reached. In C, the function prototype of the 'main' is one of the following: Welcome to the world of C 2. Explain command line arguments of main function? In C, we can supply arguments to 'main' function. The arguments that we pass to main at command prompt are called command line arguments.

These arguments are supplied at the time of invoking the program. The main function can take arguments as: It represents the number of arguments in the command line. The second argument argv is known as 'argument vector'. It is an array of char type pointers that points to the command line arguments. Size of this array will be equal to the value of argc. Following are the arguments entered in the command line C: What are the differences between malloc and calloc?

Allocation of memory at the time of execution is called dynamic memory allocation. It is done using the standard library functions malloc and calloc. It is defined in "stdlib.

It takes one argument, viz. It needs two arguments viz. Differences between malloc and calloc are: Number of arguments differ. By default, memory allocated by malloc contains garbage values. Whereas memory allocated by calloc contains all zeros. How to use realloc to dynamically increase size of an already allocated array?

This function is used to increase or decrease the size of any dynamic memory which is allocated using malloc or calloc functions. The second argument 'newsize' is the size in bytes, of a new memory region to be allocated by realloc.

This value can be larger or smaller than the previously allocated memory. The realloc function adjusts the old memory region if newsize is smaller than the size of old memory. If the newsize is larger than the existing memory size, it increases the size by copying the contents of old memory region to new memory region.

The function then deallocates the old memory region. In this case, dynamically allocated array can be used so that it is possible allocate the exact amount of memory using realloc function.

Write a program to delete a specified line from a text file. In this program, user is asked for a filename he needs to change. User is also asked for the line number that is to be deleted. The filename is stored in 'filename'. The file is opened and all the data is transferred to another file except that one line the user specifies to delete.

Program to delete a specific line. Enter file name: I am fine hope the same Enter line number of the line to be deleted: In this program, user is asked for a filename that needs to be modified.

Entered file name is stored in a char array 'filename'. This file is opened in read mode using file pointer 'fp1'. Character 'c' is used to read characters from the file and print them to the output. User is asked for the line number in the file to be deleted. The file pointer is rewinded back and all the lines of the file except for the line to be deleted are copied into another file "copy. Now "copy.

The original file is opened in read mode and the modified contents of the file are displayed on the screen.

Write a program to replace a specified line in a text file. Program to replace a specified line in a text file. In this program, the user is asked to type the name of the file. The File by name entered by user is opened in read mode. The line number of the line to be replaced is asked as input. Next the data to be replaced is asked. A new file is opened in write mode named "copy. Now the contents of original file are transferred into new file and the line to be modified is deleted.

New data is stored in its place and remaining lines of the original file are Prepared by: The copied file with modified contents is replaced with the original file's name. Both the file pointers are closed and the original file is again opened in read mode and the contents of the original file is printed as output. Write a program to find the number of lines in a text file.

Number of lines in a file can be determined by counting the number of new line characters present. Program to count number of lines in a file.

In this program, name of the file to be read is taken as input. A file by the given name is opened in read-mode using a File pointer 'fp'. This process is continued until the last character of the file EOF is encountered. The file pointer is then closed and the total number of lines is shown as output. Write a C program which asks the user for a number between 1 to 9 and shows the number.

If the user inputs a number out of the specified range, the program should show an error and prompt the user for a valid input. Program for accepting a number in a given range. Write a notes on graphics mode and video and graphics adapters. Graphics mode: Many video adapters support several different modes of resolution, all of which are divided into two general categories: Of the two modes, graphics mode is the more sophisticated.

Programs that run in graphics mode can display an unlimited variety of shapes and fonts, whereas programs running in character mode are severely limited. Programs that run entirely in graphics mode are called graphics-based programs. In character mode, the display screen is treated as an array of blocks, each of which can hold one ASCII character. In graphics mode, the display screen is treated as an array of pixels. Characters and other shapes are formed by turning on combinations of pixels.

Video adapter: A board that plugs into a personal computer to give it display capabilities. The display capabilities of a computer, however, depend on both the logical circuitry provided in the video adapter and the display monitor.

A monochrome monitor, for example, cannot display colors no matter how powerful the video adapter. Many different types of video adapters are available for PCs.

Each adapter offers several different video modes. The two basic categories of video modes are text and graphics. In graphics mode, a monitor can display any bit-mapped image. Within the text and graphics modes, some monitors also offer a choice of resolutions. At lower resolutions a monitor can display more colors.

Modern video adapters contain memory, so that the computer's RAM is not used for storing displays. In addition, most adapters have their own graphics coprocessor for performing graphics calculations. These adapters are often called graphics accelerators. Video adapters are also called video cards, video boards, video display boards, graphics cards and graphics adapters. Video and Graphics Adapters While the names to describe it are many video adapter, video card, video board, video display board, graphics card or graphics adapter its job and function within a computer system remains the same, regardless of what you call it.

Your computer's video adapter is assigned the primary task of producing the visual output from your system. It is the hardware that works between your system's processor and monitor. It relays the information received from the programs and applications running on your system computed by the processor to the monitor that allows you to view the information and images on your screen.

A video adapter is board that plugs into a personal computer to give it display capabilities. Those capabilities of a computer, however, depend on both the logical circuitry provided in the video adapter and the display monitor. A monochrome monitor, for example, can't display colors no matter how powerful the video adapter. The term video adapter applies to either integrated or separate video circuitry. Each adapter offers several video modes. A file by the given name is opened in read-mode using a File pointer 'fp'.

This process is continued until the last character of the file EOF is encountered. The file pointer is then closed and the total number of lines is shown as output.

Write a C program which asks the user for a number between 1 to 9 and shows the number. If the user inputs a number out of the specified range, the program should show an error and prompt the user for a valid input. Program for accepting a number in a given range. Write a notes on graphics mode and video and graphics adapters. Graphics mode: Many video adapters support several different modes of resolution, all of which are divided into two general categories: Of the two modes, graphics mode is the more sophisticated.

Programs that run in graphics mode can display an unlimited variety of shapes and fonts, whereas programs running in character mode are severely limited. Programs that run entirely in graphics mode are called graphics-based programs. In character mode, the display screen is treated as an array of blocks, each of which can hold one ASCII character.

In graphics mode, the display screen is treated as an array of pixels. Characters and other shapes are formed by turning on combinations of pixels. Video adapter: A board that plugs into a personal computer to give it display capabilities.

The display capabilities of a computer, however, depend on both the logical circuitry provided in the video adapter and the display monitor. A monochrome monitor, for example, cannot display colors no matter how powerful the video adapter. Many different types of video adapters are available for PCs. Each adapter offers several different video modes. The two basic categories of video modes are text and graphics.

In graphics mode, a monitor can display any bit-mapped image. Within the text and graphics modes, some monitors also offer a choice of resolutions. At lower resolutions a monitor can display more colors. Modern video adapters contain memory, so that the computer's RAM is not used for storing displays. In addition, most adapters have their own graphics coprocessor for performing graphics calculations. These adapters are often called graphics accelerators.

Video adapters are also called video cards, video boards, video display boards, graphics cards and graphics adapters. Video and Graphics Adapters While the names to describe it are many video adapter, video card, video board, video display board, graphics card or graphics adapter its job and function within a computer system remains the same, regardless of what you call it.

Your computer's video adapter is assigned the primary task of producing the visual output from your system. It is the hardware that works between your system's processor and monitor. It relays the information received from the programs and applications running on your system computed by the processor to the monitor that allows you to view the information and images on your screen.

A video adapter is board that plugs into a personal computer to give it display capabilities. Those capabilities of a computer, however, depend on both the logical circuitry provided in the video adapter and the display monitor.

A monochrome monitor, for example, can't display colors no matter how powerful the video adapter. The term video adapter applies to either integrated or separate video circuitry. Each adapter offers several video modes. At lower resolutions, a monitor can display more colors.

In non-accelerated unaccelerated graphics adapters, the computer needed to change each pixel individually to change the image on the screen.

Having the graphics handled by the processor didn't become much of an issue until graphical user interfaces like Windows for example gained in popularity. Systems began to slow down as the CPU was left trying to move large amounts of data from the system RAM to the video card. As always with technology, it didn't take long for the bottle-neck to be sorted out. The biggest difference between accelerated and non-accelerated cards is that with accelerated video cards, the CPU Prepared by: Since the video card has its own processor, it is able to perform most of the work, leaving your CPU free to process other tasks.

By programming pdf c advanced example

A graphics accelerator, for example, is a type of video adapter that contains its own processor to boost performance levels. These processors are specialized for computing graphical transformations, so they achieve better results than the general-purpose CPU used by the computer. In addition, they free up the computer's CPU to execute other commands while the graphics accelerator is handling graphics computations. The popularity of graphical applications, and especially multimedia applications and computer games, has made graphics accelerators not only a common enhancement, but a necessity.

Most computer manufacturers now bundle a graphics accelerator with their mid-range and high-end systems. Aside from the graphics processor used, some other characteristics that differentiate graphics accelerators are: Graphics accelerators have their own memory, which is reserved for storing graphical representations.

Because of the demands of video systems, video memory needs to be faster than main memory. The amount of memory determines how much resolution and how many colors can be displayed. Some accelerators use conventional DRAM, but others use a special type of video RAM, which enables both the video circuitry and the processor to simultaneously access the memory. Each graphics accelerator is designed for a particular type of video bus AGP or PCI So now that you know the basics behind how your video adapter works, there is another important topic to discuss when it comes to upgrading your system's video.

Unfortunately, it's not as simple as buying any video card on the market and plugging it in. There are three main types of video upgrades and before buying you need to know which type can be used in your system.

Example pdf c advanced programming by

To upgrade an add-on video card, you need to remove the card and drivers and install the new video card and drivers. Motherboard Video-only Chipset If your system supports a video-only chipset on the motherboard, your motherboard has integrated video which is using your system memory. Many PCs come with this type of video, but they will also have an open AGP expansion slot on the motherboard that allows you to add a video card rather than using the on-board video.

To upgrade in this scenario, you'll need to disable the on-board video and add an AGP video card and install drivers for the new card. Motherboard With Integrated Video This type set-up offers only on-board video — you won't have an extra AGP slot that you can use to install a new video card. VGA x The ROM BIOS Basic Input Output System provides device control for the PC's major devices disk, video, keyboard, serial port, printer , allowing a programmer to communicate with these devices without needing detailed knowledge of their operation.

The interrupts 10H through to 1AH each access a different routine. The routines normally preserve all registers except AX and the flags. Some registers are altered if they return values to the calling process. The routine executed will depend upon the contents of a particular CPU register. It is necessary to use a C definition of the CPU programming model, this allows the registers to be initialised with the correct values before the interrupt is generated.

The definition also provides a convienent place to store the returned register values. Luckily, the definition has already been created, and resides in the header file dos. It is a union of type REGS, which has two parts, each structures. One structure contains the eight bit registers accessed by. To generate the desired interrupt, a special function call has been provided. This function accepts the interrupt number, and pointers to the programming model union for the entry and return register values.

The following program demonstrates the use of these concepts to set the display mode to 40x25 color. Write a note on Port accessing using C Ans: The C language can be used to transfer data to and from the contents of the various registers and controllers associated with the IBM-PC. These registers and control devices are port mapped, and are accessed using special IN and OUT instructions. Most C language support library's include functions to do this.

The following is a brief description of how this may be done. Carry out following Steps to Run 1. Save Program 2. Compile Program. Run Program. Now Open Command Prompt. Move to the directory where program is saved. Type following command. The sum is: Step 1: Write a Program Step 2: Step 3: Click on DOS Shell.

Step 4: Inside Command Prompt type this command. Hit Enter , You will get following Output. Content will be written successfully to file Explanation of Program: We have to files with us , we are opening one file in read mode and another file in write mode. Firstly open file in the read mode. Open one file in the read mode another file in the write mode.

Whenever we find End of file character then we terminate the process of reading the file and writing the file. SMJC Percent: To copy a text from one file to another we have to follow following Steps: This macro will expand to the name of current file path. Enter the number of Capacitors: Enter the number of Resistances: Write a note on Parallel Port Programming in C? The Parallel Port is the most commonly used port for interfacing home made projects. This port will allow the input of up to 9 bits or the output of 12 bits at any one given time, thus requiring minimal external circuitry to implement many simpler tasks.

The port is composed of 4 control lines, 5 status lines and 8 data lines. There may also be a D-Type 25 pin male connector. This will be a serial RS port and thus, is a totally incompatible port. This standard defines 5 modes of operation which are as follows, 1. Compatibility Mode.

Nibble Mode. Protocol not Described in this Document 3. Byte Mode. Protocol not Described in this Document 4. The aim was to design new drivers and devices which were compatible with each other and also backwards compatible with the Standard Parallel Port SPP. Data, Control and status lines are connected to there corresponding registers inside the computer. So by manipulating these registers in program , one can easily read or write to parallel port with programming languages like 'C' and BASIC.

The registers found in standard parallel port are , 1 data register 2 Status register 3 Control register Prepared by: What is INT86 function? The value is return in AX register. How will you interact with hardware? There are many ways to interact with hardware. Using high level language functions. SYS 4. Direct programming the hardware. As programmer moves from fist to last approach his reliability decreases and speed increases.

Write Program to find whether mouse driver is loaded or not. These two structures contain some 1-byte long and 2-byte long variables which indirectly represent CPU's registers. By placing 0 sub-function in ax register and Prepared by: If mouse driver is not loaded, it returns 0 in ax register. All return values are accessed using 'o' i. Write a Program to show the mouse pointer. Que 29 program only reported mouse driver loaded or not. Even if driver is avilable,we have no signs of mouse pointer.

To view mouse pointer,we have to use sub-function 1. Look at the program presented below. We have placed 1 in ax register and invoked mouse interrupt to see the pointer.

Since we are in text mode, our pointer is a rectangular box. We can observe an arrow if we switch to graphics mode. Write a Program to hide the mouse pointer. Mouse cursor still remains, even after our program is terminated. Look at the following program. Press any key to terminate the program This function is quite a useful function,when writing programs that draw a line or rectangle as we move the mouse.

While writing those programs we don't want mouse pointer to erase what we draw hence we hide the pointer. Write a Program to show the position of the mouse pointer. For writing any useful program with mouse support,we need to know the x,y coordinates of the mouse position. The below program prints the position of the mouse,as we mouse the mouse. This loop continues until a key is hit. In loop,we used sub-function 3 and invoked mouse interrupt. Maximum screen resolution for mouse in text mode is x and in graphics mode is x Write a Program to print which mouse button is pressed.

Knowing which button is pressed is very important task. The program below prints which button is pressed as soon as we press any button.

In while we used the same sub-function 3 and invoked mouse interrupt. This subfunction even returns button press information in bx register. Entire button press information is stored in the first 3 bits of the bx register.

If the first bit's value is 1 then the left button is Prepared by: If the second bit's value is 1 then the right button is pressed,if value is 0 then it is not pressed. If the last bit's value is 1 then the middle button is pressed,if value is 0 then it is not pressed. Write a Program to set the position of the mouse pointer on the screen. Sometimes we need to set the position of the mouse pointer, just as we set the position of the keyboard's cursor using gotoxy.

Write a Program to switch to graphics mode. The program below switches text mode to graphcs mode. After executing this program,observe the mouse pointer. Now,it's in an arrow shape. Try to execute program-4 in graphics mode and observe the maximum screen resolution for mouse is increased to x Press any key to exit" ; getch ; i.

This function takes 3 arguments;graphics driver, graphics mode,path to the driver. Path is null since the driver files are located in the current directory.

This function initializes graphics system and when the program terminates we come to text mode by using restorecrtmode function. Write a Program to restrict the mouse pointer within a boundary. Sometimes,in our program,we need to restrict the mouse pointer with in a screen boundary. In order to do that,we need to specify the top,left co-ordinates as well bottom,right co-ordinates. Sub-functions 7,8 are used to limit the pointer within a boundary.

Write a C programm to draw Free-hand drawing. If you ever wonder,how pencil tool in paint works. Then,the following program shows how it can be written in C.

The following program makes use of some of the subfunction, which we already disussed above,and shows how they can be used to write useful programs like free-hand drawing. Just,go through the following program. Since you have gone through the program,you must have understood the logic.

Write a C program for Line drawing using mouse. Following program shows how to draw a line interactively using mouse.

You might also like: COMPETITIVE PROGRAMMING 1 PDF

If you knowhow to draw a line,there is no big deal in developing a program that draws a square. So,carefully observe and understand the following program. In order to do that,the above program uses save and restore functions. These two functions captures and restores screen contents. The most remarkable ones are: Object-oriented programming: The possibility to orientate programming to objects allows the programmer to design applications from a point of view more like a communication between objects rather than on a structured sequence of code.

In addition it allows a greater reusability of code in a more logical and productive way. Modular programming: Saving time since it is not necessary to recompile the complete application when making a single change but only the file that contains it. C Compatibility: