Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: May 2014

Thursday, May 8, 2014

ISC Computer Science Practicals: Solved


Write a program to declare a matrix A [][] of order (MXN)
where 'M' is the number of rows and 'N' is the number of
columns such that both M and N must be greater than 2 and
less than 20. Allow the user to input integers into this matrix.
Perform the following tasks on the matrix:

1. Display the input matrix
2. Find the maximum and minimum value in the matrix and display
them along with their position.
3. Sort the elements of the matrix in ascending order using any
standard sorting technique and rearrange them in the matrix.

Output the rearranged matrix.

Sample input Output
INPUT:
M=3
N=4
Entered values: 8,7,9,3,-2,0,4,5,1,3,6,-4
Original matrix:

8 7 9 3
-2 0 4 5
1 3 6 -4

Largest Number: 9
Row: 0
Column: 2
Smallest Number: -4
Row=2
Column=3

Rearranged matrix:

-4 -2 0 1
3 3 4 5
6 7 8 9

Monday, May 5, 2014

open GL Programming in LINUX


To compile a program (using open GL graphics library) in Linux, go to the current directory where the program is residing say test.c. type the following command gcc -o xyz test.c -lglut -lGLU -lGL -lGLU make sure you have the open GL library installed! After the execution of the command a output file with name xyz will be created in the current directory. To run the output file type in the following command ./xyz

To sum up consider a program vinod.c in the folder Graphics, to execute it perform the following steps.
administrator@ubuntu:~/Graphics$ gcc -o vin vinod.c -lglut -lGLU -lGL -lGLU
administrator@ubuntu:~/Graphics$ ./vin


Here is an example of a simple program which will just create a window with a text

#include <GL/glut.h>
void
display(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("MY FIRST GRAPHICS PROGRAM");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}