Skip to main content

Posts

Showing posts from March, 2020

Basic Building Blocks Of The C Programming | VCMIT

Basic Building Blocks Of The C Programming You have seen the basic structure of a C program, so it will be easy to understand other basic building blocks of the C programming language. Tokens in C A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens − printf("Hello, World! \n"); The individual tokens are − printf (    "Hello, World! \n" ) ; Semicolons In a C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity. Given below are two different statements − printf("Hello, World! \n"); return 0; Comments Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below − /* my first program in C */ You cannot have comments withi

Hello World Example In C Programming | VCMIT

Hello World Example A C program basically consists of the following parts − Preprocessor Commands Functions Variables Statements & Expressions Comments Let us look at a simple code that would print the words "Hello World" − INPUT #include <stdio.h> void main {    /* my first program in C */    printf("Hello, World! \n");    getch; } Let us take a look at the various parts of the above program − The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation. The next line int main() is the main function where the program execution begins. The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program. The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen. The next line

Applications Of C Programming | Audience & Prerequisites | VCMIT

Applications of C Programming C was initially used for system development work, particularly the programs that make-up the operating system. C was adopted as a system development language because it produces code that runs nearly as fast as the code written in assembly language. Some examples of the use of C are - Operating Systems Language Compilers Assemblers Text Editors Print Spoolers Network Drivers Modern Programs Databases Language Interpreters Utilities Audience This tutorial is designed for software programmers with a need to understand the C programming language starting from scratch. This C tutorial will give you enough understanding on C programming language from where you can take yourself to higher level of expertise. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages will help you in understanding the C programming concepts and move fast

What Is C Programming? | Why To Learn C Programming | VCMIT

What Is C Programming C programming is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers. Why to Learn C Programming? C programming language is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain. I will list down some of the key advantages of learning C Programming: Easy to learn Structured language It produces efficient programs It can handle low-level activities It can be compiled on a variety of computer platforms Facts about C C was invented to write an operating system called UNIX. C is a successor of B language which was introduced aroun

Draw The Moving Car On The Screen Program In C | VCMIT

The Moving Car Program In C  INPUT #include <stdio.h> #include <graphics.h> #include <conio.h> #include <dos.h> int main() { int gd = DETECT, gm; int i, maxx, midy; initgraph(&gd, &gm, "C:\\TURBOC3\\BGI"); maxx = getmaxx(); midy = getmaxy()/2; for (i=0; i < maxx-150; i=i+5) { cleardevice(); setcolor(WHITE); line(0, midy + 37, maxx, midy + 37); setcolor(YELLOW); setfillstyle(SOLID_FILL, RED); line(i, midy + 23, i, midy); line(i, midy, 40 + i, midy - 20); line(40 + i, midy - 20, 80 + i, midy - 20); line(80 + i, midy - 20, 100 + i, midy); line(100 + i, midy, 120 + i, midy); line(120 + i, midy, 120 + i, midy + 23); line(0 + i, midy + 23, 18 + i, midy + 23); arc(30 + i, midy + 23, 0, 180, 12); line(42 + i, midy + 23, 78 + i, midy + 23); arc(90 + i, midy + 23, 0, 180, 12); line(102 + i, midy + 23, 120 + i, midy + 23); line(28 + i, midy, 43 + i, midy - 15); line(43 + i, midy - 15, 57 + i, midy - 15); line(57 + i, midy - 15, 57 + i, midy); line(57 +

Develop The Program For The DDA Line Drawing Algorithm In C | VCMIT

The DDA Line Drawing Algorithm  INPUT #include <graphics.h> #include <stdio.h> #include <math.h> #include <dos.h> void main( ) { float x,y,x1,y1,x2,y2,dx,dy,step; int i,gd=DETECT,gm; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); printf("Enter the value of x1 and y1 : "); scanf("%f%f",&x1,&y1); printf("Enter the value of x2 and y2: "); scanf("%f%f",&x2,&y2); dx=abs(x2-x1); dy=abs(y2-y1); if(dx>=dy) step=dx; else step=dy; dx=dx/step; dy=dy/step; x=x1; y=y1; i=1; while(i<=step) { putpixel(x,y,5); x=x+dx; y=y+dy; i=i+1; delay(100); } getch(); closegraph(); } OUTPUT

Bresenham’s Line Drawing Algorithm Program In C | VCMIT

Bresenham’s Line Drawing Algorithm Program In C INPUT #include<stdio.h> #include<graphics.h> void drawline(int x0, int y0, int x1, int y1) { int dx, dy, p, x, y; dx=x1-x0; dy=y1-y0; x=x0; y=y0; p=2*dy-dx; while(x<x1) { if(p>=0) { putpixel(x,y,7); y=y+1; p=p+2*dy-2*dx; } else { putpixel(x,y,7); p=p+2*dy; } x=x+1; } } int main() { int gdriver=DETECT, gmode, error, x0, y0, x1, y1; initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi"); printf("Enter co-ordinates of first point: "); scanf("%d%d", &x0, &y0); printf("Enter co-ordinates of second point: "); scanf("%d%d", &x1, &y1); drawline(x0, y0, x1, y1); getch(); } OUTPUT

Create House Like Structure Perform Operations Program In C | VCMIT

Program to create a house like figure and perform the following operations.  Scaling about the origin followed by translation.  Scaling with reference to an arbitrary point. Reflect about the line y = mx + c. INPUT #include <stdio.h> #include <graphics.h> #include <stdlib.h> #include <math.h> #include <conio.h> void reset (int h[][2]) { int val[9][2] = { { 50, 50 },{ 75, 50 },{ 75, 75 },{ 100, 75 }, { 100, 50 },{ 125, 50 },{ 125, 100 },{ 87, 125 },{ 50, 100 } }; int i; for (i=0; i<9; i++) { h[i][0] = val[i][0]-50; h[i][1] = val[i][1]-50; } } void draw (int h[][2]) { int i; setlinestyle (DOTTED_LINE, 0, 1); line (320, 0, 320, 480); line (0, 240, 640, 240); setlinestyle (SOLID_LINE, 0, 1); for (i=0; i<8; i++) line (320+h[i][0], 240-h[i][1], 320+h[i+1][0], 240-h[i+1][1]); line (320+h[0][0], 240-h[0][1], 320+h[8][0], 240-h[8][1]); } void rotate (int h[][2], float angle) { int i; for (i=0; i<9; i++) { int xnew, ynew; xnew = h[i][0] * cos (angle) - h[i]

Perform 2D Rotation On A Given Object Program In C | VCMIT

2D Rotation On A Given Object Program INPUT #include<stdio.h> #include<graphics.h> void main() { int gd=DETECT,gm; initgraph(&gdriver,&gmode,"C//TurboC3//BGI"); int x1,y1,x2,y2 ; float b1,b2; float t,deg; printf(“Enter the coordinates of Line: ”); scanf(“%d%d%d%d”,&x1,&y1,&x2,&y2); setcolor(6); line(x1,y1,x2,y2); getch(); //cleardevice(); printf(“Enter the angle of rotation: “); scanf(“%f”,&deg); t=(22*deg)/(180*7); b1=abs((x2*cos(t))-(y2*sin(t))); b2=abs((x2*sin(t))+(y2*cos(t))); line(x1,y1,b1,b2); getch(); closegraph(); } OUTPUT

Perform Smiling Face Animation Using Graphic Functions Program In C | VCMIT

Smiling Face Animation Program INPUT #include<graphics.h> #include<conio.h> #include<stdlib.h> main() { int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75; void *p; initgraph(&gd,&gm,"C:\\TC\\BGI"); setcolor(YELLOW); circle(50,100,25); setfillstyle(SOLID_FILL,YELLOW); floodfill(50,100,YELLOW); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); fillellipse(44,85,2,6); fillellipse(56,85,2,6); ellipse(50,100,205,335,20,9); ellipse(50,100,205,335,20,10); ellipse(50,100,205,335,20,11); area = imagesize(left, top, left + 50, top + 50); p = malloc(area); setcolor(WHITE); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextxy(155,451,"Smiling Face Animation"); setcolor(BLUE); rectangle(0,0,639,449); while(!kbhit()) { temp1 = 1 + random ( 588 ); temp2 = 1 + random ( 380 ); getimage(left, top, left + 50, top + 50, p); putimage(left, top, p, XOR_PUT); putimage(temp1 , temp2, p, XOR_PUT); delay(100); left = temp1; top = temp2; } getch(); closegra

Draw A Simple Hut On The Screen Program In C | VCMIT

A Simple Hut On The Screen INPUT #include<graphics.h> #include<conio.h> int main(){ int gd = DETECT,gm; initgraph(&gd, &gm, "C:\\TURBOC3\\BGI"); setcolor(WHITE); rectangle(150,180,250,300); rectangle(250,180,420,300); rectangle(180,250,220,300); line(200,100,150,180); line(200,100,250,180); line(200,100,370,100); line(370,100,420,180); setfillstyle(SOLID_FILL, BROWN); floodfill(152, 182, WHITE); floodfill(252, 182, WHITE); setfillstyle(SLASH_FILL, BLUE); floodfill(182, 252, WHITE); setfillstyle(HATCH_FILL, GREEN); floodfill(200, 105, WHITE); floodfill(210, 105, WHITE); getch(); closegraph(); return 0; } OUTPUT

Write A Program To Fill A Circle Using Flood Fill Algorithm | VCMIT

Fill A Circle Using Flood Fill Algorithm INPUT #include<stdio.h> #include<conio.h> #include<graphics.h> void floodFill(int, int, int, int); int midx=319, midy=239; void main() { int gdriver=DETECT, gmode, x,y,r; initgraph(&gdriver, &gmode, "C:\\TURBOCS3\\BGI"); cleardevice(); printf("Enter the Center of circle (X,Y) : "); scanf("%d %d",&x,&y); printf("Enter the Radius of circle R : "); scanf("%d",&r); circle(midx+x,midy-y,r); getch(); floodFill(midx+x,midy-y,13,0); getch(); closegraph(); } void floodFill(int x, int y, int fill, int old) { if(getpixel(x,y) == old) { putpixel(x,y,fill); delay(5); floodFill(x+1,y,fill,old); floodFill(x-1,y,fill,old); floodFill(x,y+1,fill,old); floodFill(x,y-1,fill,old); } } OUTPUT

Write A Program To Implement Liang - Barsky Line Clipping Algorithm | VCMIT

Write A Program To Implement Liang - Barsky Line Clipping Algorithm INPUT #include<stdio.h> #include<graphics.h> #include<math.h> #include<dos.h> void main() { int i,gd=DETECT,gm; int x1,y1,x2,y2,xmin,xmax,ymin,ymax,xx1,xx2,yy1,yy2,dx,dy; float t1,t2,p[4],q[4],temp; x1=120; y1=120; x2=300; y2=300; xmin=100; ymin=100; xmax=250; ymax=250; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); rectangle(xmin,ymin,xmax,ymax); dx=x2-x1; dy=y2-y1; p[0]=-dx; p[1]=dx; p[2]=-dy; p[3]=dy; q[0]=x1-xmin; q[1]=xmax-x1; q[2]=y1-ymin; q[3]=ymax-y1; for(i=0;i<4;i++) { if(p[i]==0) { printf("line is parallel to one of the clipping boundary"); if(q[i]>=0) { if(i<2) { if(y1<ymin) { y1=ymin; } if(y2>ymax) { y2=ymax; } line(x1,y1,x2,y2); } if(i>1) { if(x1<xmin) { x1=xmin; } if(x2>xmax) { x2=xmax; } line(x1,y1,x2,y2); } } } } t1=0; t2=1; for(i=0;i<4;i++) { temp=q[i]/p[i]; if(p[i]<0) { if(t1<=temp) t1=temp; } else { if(t2>temp) t2=temp; }

Draw The Walking Man On The Screen Program In C | BGI | VCMIT

Draw The Walking Man On The Screen Program In C INPUT #include<stdio.h> #include<graphics.h> #define ScreenWidth getmaxx() #define ScreenHeight getmaxy() #define GroundY ScreenHeight*0.75 int ldaisp=0; void DrawManWithUmbrella(int a,int ldaisp) { //Draw Umbrella pieslice(a+20,GroundY-120,0,180,40); line(a+20,GroundY-120,a+20,GroundY-70); //Draw head circle(a,GroundY-90,10); line(a,GroundY-80,a,GroundY-30); //Draw hand line(a,GroundY-70,a+10,GroundY-60); line(a,GroundY-65,a+10,GroundY-55); line(a+10,GroundY-60,a+20,GroundY-70); line(a+10,GroundY-55,a+20,GroundY-70); //Draw legs line(a,GroundY-30,a+ldaisp,GroundY); line(a,GroundY-30,a-ldaisp,GroundY); } void Rain(int a) { int i,rx,ry; for(i=0;i<400;i++) { rx=rand() % ScreenWidth; ry=rand() % ScreenHeight; if(ry<GroundY-4) { if(ry<GroundY-120 || (ry>GroundY-120 && (rx<a-20 || rx>a+60))) line(rx,ry,rx+0.5,ry+4); } } } void main() { int gd=DETECT,gm,a=0; initgraph(&gd,&gm,"C:\\TC\\BGI"

Drawing Different Shapes Program In C | BGI | VCMIT

Drawing Different Shapes Program In C INPUT #include<graphics.h> #include<conio.h> main() {    int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;    initgraph(&gd, &gm, "C:\\TC\\BGI");    rectangle(left, top, right, bottom);    circle(x, y, radius);    bar(left + 300, top, right + 300, bottom);    line(left - 10, top + 150, left + 410, top + 150);    ellipse(x, y + 200, 0, 360, 100, 50);    outtextxy(left + 100, top + 325, "My first C graphics program");    getch();    closegraph();    return 0; } OUTPUT

Moving Fish Program In C| BGI | VCMIT

Moving Fish Program In C IINPUT #include<stdlib.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<ctype.h> void main() {         int gd=DETECT,gm;         int xincr=0,newy=0,yincr=5;         initgraph(&gd,&gm," ");         cleardevice();         while(!kbhit())         {                 ellipse(520-xincr,200,30,330,90,30);                 circle(450-xincr,193,3);                 line(430-xincr,200,450-xincr,200);                 line(597-xincr,185,630-xincr,170);                 line(597-xincr,215,630-xincr,227);                 line(630-xincr,170,630-xincr,227);                 line(597-xincr,200,630-xincr,200);                 line(597-xincr,192,630-xincr,187);                 line(597-xincr,207,630-xincr,213);                 line(500-xincr,190,540-xincr,150+newy);                 line(530-xincr,190,540-xincr,150+newy);                 if(xincr>=500)                         xincr=0;                 if(newy>=82)  

Python Turtle Python Logo Program | Turtle | VCMIT

Turtle Python Logo Program INPUT import turtle l1 = [[0.0, -238.0], [92.6, -219.3], [168.3, -168.3], [219.3, -92.6], [238.0, 0.0], [219.3, 92.6], [168.3, 168.3], [92.6, 219.3], [0.0, 238.0], [-92.6, 219.3], [-168.3, 168.3], [-219.3, 92.6], [-238.0, 0.0], [-219.3, -92.6], [-168.3, -168.3], [-92.6, -219.3], [0.0, -238.0], [0.0, -256.0], [-99.6, -235.9], [-181.0, -181.0], [-235.9, -99.6], [-256.0, 0.0], [-235.9, 99.6], [-181.0, 181.0], [-99.6, 235.9], [0.0, 256.0], [99.6, 235.9], [181.0, 181.0], [235.9, 99.6], [256.0, 0.0], [235.9, -99.6], [181.0, -181.0], [99.6, -235.9], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0]] l2 = [[-83.1, 17.3], [-64.3, 16.4], [-13.81, 32.1], [3.2, 70.7], [-18.9, 115.4], [-70.5, 130.1], [-76.5, 129.9], [-82.7, 129.3], [-82.7, 128.7], [-82.7, 128.1], [-93.8, 128.1], [-104.9, 128.1], [-104.9, 127.5], [-104.9, -128.6], [-82.7, -126.9], [-104.9, -128.6], [-104.8, 20.4]] l3 = [[-82.7, 110.4], [-75.9, 111.0], [-69.7, 111.2],

Python TKinter Theme Program | TKinter | VCMIT

Python TKinter Theme Program | TKinter | WaoFamHub INPUT from tkinter import Tk, Label, Button, Entry, X import tkinter from tkinter import ttk from tkinter import messagebox class Root(Tk):     def __init__(self):         super().__init__()         for x in [ttk.Label, ttk.Button, ttk.Entry, ttk.Checkbutton, ttk.Radiobutton]:             x(self, text='Some ' + x.__name__).pack(fill=X)         pb = ttk.Progressbar(self, length=100)         pb.pack(fill=X)         pb.step(33)         ttk.Label(self, text='Select theme:').pack(pady=[50, 10])         self.style = ttk.Style()         self.combo = ttk.Combobox(self, values=self.style.theme_names())         self.combo.pack(pady=[0, 10])         button = ttk.Button(self, text='Apply')         button['command'] = self.change_theme         button.pack(pady=10)     def change_theme(self):         content = self.combo.get()         try:             self.style.theme_use(content)         except:             print(&qu

Python TKinter Text Editor Program | TKinter | VCMIT

Python TKinter Text Editor Program INPUT from tkinter import * from tkinter.filedialog import * from tkinter.messagebox import * from tkinter.font import Font from tkinter.scrolledtext import * import file_menu import edit_menu import format_menu import help_menu root = Tk() root.title("Text Editor-Untiltled") root.geometry("300x250+300+300") root.minsize(width=400, height=400) text = ScrolledText(root, state='normal', height=400, width=400, wrap='word', pady=2, padx=3, undo=True) text.pack(fill=Y, expand=1) text.focus_set() menubar = Menu(root) file_menu.main(root, text, menubar) edit_menu.main(root, text, menubar) format_menu.main(root, text, menubar) help_menu.main(root, text, menubar) root.mainloop() OUTPUT

Python Simple Calculator Program | TKinter Calculator Program | VCMIT

Python Simple Calculator Program With TKinter Calculator INPUT from tkinter import Tk, Label, Button, Entry class Root(Tk):     def __init__(self):         super().__init__()         self.title_label = Label(self, text="A Simple Calculator :)")         self.title_label.pack()         self.entry = Entry(self)         self.entry.pack()         self.entry.insert(0, "1+2")         self.label = Label(self, text="")         self.label.pack()         self.button = Button(self, text="Compute", command=self.onclick)         self.button.pack()     def onclick(self):         self.label.configure(text=str(eval(self.entry.get()))) root = Root() root.mainloop() OUTPUT

Write a java program for multiplying two matrices and print the product for the same | VCMIT

Two matrices and print the product for the same. INPUT public class Matrix1{ public static void main(String args[]){    int a[][]={{1,1,1},{2,2,2},{3,3,3}};  int b[][]={{1,1,1},{2,2,2},{3,3,3}};      int c[][]=new int[3][3];    for(int i=0;i<3;i++){  for(int j=0;j<3;j++){  c[i][j]=0;    for(int k=0;k<3;k++)    {    c[i][j]+=a[i][k]*b[k][j];    } System.out.print(c[i][j]+" ");  } System.out.println();  }  }} OUTPUT

Write a java program to add two matrices and print the resultant matrix | VCMIT

Add two matrices and print the resultant matrix. INPUT public class Matrix{ public static void main(String args[]){  int a[][]={{1,3,4},{2,4,3},{3,4,5}};  int b[][]={{1,3,4},{2,4,3},{1,2,4}};    int c[][]=new int[3][3];    for(int i=0;i<3;i++){  for(int j=0;j<3;j++){  c[i][j]=a[i][j]+b[i][j];  System.out.print(c[i][j]+" ");  }  System.out.println();  }  }} OUTPUT

Write a java program to implement multiple inheritance | VCMIT

Multiple Inheritance. INPUT interface Car {     int speed=60;     public void distanceTravelled(); } interface Bus {     int distance=100;     public void speed(); } public class Vehicle implements Car,Bus {     int distanceTravelled;     int averageSpeed;     public void distanceTravelled()     {         distanceTravelled=speed*distance;         System.out.println("Total Distance Travelled is : "+distanceTravelled);     }     public void speed()     {         int averageSpeed=distanceTravelled/speed;         System.out.println("Average Speed maintained is : "+averageSpeed);     }     public static void main(String args[])     {         Vehicle v1=new Vehicle();         v1.distanceTravelled();         v1.speed();     } } OUTPUT

Write a java program to implement method overriding | VCMIT

Method Overriding INPUT class Human{      public void eat()    {       System.out.println("Human is eating");    } } class Boy extends Human{      public void eat(){       System.out.println("Boy is eating");    }    public static void main( String args[]) {       Boy obj = new Boy();           obj.eat();    } } OUTPUT

Write a java program to implement single level inheritance. | VCMIT

Single Level Inheritance.  INPUT class Single{  static int num1=10;  static int num2=5; } class Main extends Single{  public static void main(String[] args){  int num3=2;  int result=num1+num2+num3;  System.out.println("Result of child class is "+result);  } } OUTPUT