C and C++

Explain reference variable

A reference variable is just another name to an already existing variable. Creating Reference Variable The reference variable is created using the & symbol. For example, let a is a variable and we can create a reference variable of a as x as follows, int a =10; int &x=a; Here variable x is a reference […]

C and C++

List & explain Basic features of object oriented programming language

Basic concepts and features of object oriented programming language like C++. Following are the features or basic concepts of C++ programming language. 1. Objects and Classes 2. Data abstraction 3. Data encapsulation 4. Inheritance 5. Polymorphism 6. Binding 7. Message passing 1. Objects and Classes: Classes are user-defined data types on which objects are created. […]

C and C++

Difference between Procedure Oriented Programming and Object Oriented Programming

Procedure oriented programming Object oriented Programming Emphasis is given more to procedures (functions) Emphasis is given more to data in OOP The programming task is divided into a collection of data structures and methods or functions. The programming task is divided into objects (consisting of data members and associated member functions) Procedures are being separated […]

Computer Graphics

Display Window Management Using GLUT

We can consider a simplified example, minimal number of operations for displaying a picture. Step 1: initialization of GLUT We are using the OpenGL Utility Toolkit, our first step is to initialize GLUT. This initialization function could also process any command line arguments, but we will not need to use these parameters for our first […]

Computer Graphics

Graphics Functions

It provides users with a variety of functions for creating and manipulating pictures The basic building blocks for pictures are referred to as graphics output primitives Attributes are properties of the output primitives We can change the size, position, or orientation of an object using geometric transformations Modeling transformations, which are used to construct a […]

Computer Graphics

Define Computer Graphics & its applications

Computer graphics is an art of drawing pictures, lines, charts, etc. using computers with the help of programming. Computer graphics image is made up of number of pixels. Pixel is the smallest addressable graphical unit represented on the computer screen. Applications of Computer Graphics Graphs and Charts An early application for computer graphics is the […]

C and C++

C / C++ program to emulate the unix ln command

#include<stdio.h> #include<sys/types.h> #include<unistd.h> #include<string.h> int main(int argc, char * argv[]) { if(argc < 3 || argc > 4 || (argc == 4 && strcmp(argv[1],”-s”))) { printf(“Usage: ./a.out [-s] \n”); return 1; } if(argc == 4) { if((symlink(argv[2], argv[3])) == -1) printf(“Cannot create symbolic link\n”) ; else printf(“Symbolic link created\n”) ; } else { if((link(argv[1], argv[2])) […]

C and C++ Compiler Design

C/C++ program that outputs the contents of its Environment list

#include<stdio.h> int main(int argc, char* argv[ ]) { int i; char **ptr; extern char **environ; for( ptr = environ; *ptr != 0; ptr++ ) /*echo all env strings*/ printf(“%s\n”, *ptr); return 0; } OUTPUT SSH_AGENT_PID=3207 HOSTNAME=localhost.localdomain DESKTOP_STARTUP_ID= SHELL=/bin/bash TERM=xterm HISTSIZE=1000 KDE_NO_IPV6=1 GTK_RC_FILES=/etc/gtk/gtkrc:/root/.gtkrc-1.2-gnome2 WINDOWID=44040273 OLDPWD=/root/tan QTDIR= QTINC= USER= LS_COLORS=no=00:fi=00:di=00;34:l GNOME_KEYRING_SOCKET= SSH_AUTH_SOCK=/tmp/ssh-SEwJHJ3149/agent.3149 KDEDIR=/usr SESSION_MANAGER= MAIL=/var/spool/mail/root DESKTOP_SESSION=default PATH= […]

C and C++ Compiler Design

POSIX compliant program that prints the POSIX defined configuration options supported on any given system using feature test macros

#define _POSIX_SOURCE #define _POSIX_C_SOURCE 199309L #include<stdio.h> #include<unistd.h> int main() { #ifdef _POSIX_JOB_CONTROL printf(“System supports job control\n”); #else printf(“System does not support job control \n”); #endif #ifdef _POSIX_SAVED_IDS printf(“System supports saved set-UID and saved set-GID\n”); #else printf(“System does not support saved set-UID and saved set-GID \n”); #endif #ifdef _POSIX_CHOWN_RESTRICTED printf(“chown_restricted option is %d\n”, _POSIX_CHOWN_RESTRICTED); #else printf(“System […]