Posts

Program for checking whether input number is Prime or not

#include<stdio.h> #include<conio.h> void main() { int n,n1,i; printf("\nEnter any positive integer number to check"); scanf("%d",&n); if(n==1 || n==2) printf("\nThe number is Prime"); else { i=2; while(i<=n) { if(n%i==0) break; i++; } if(n==i) printf("\nThe Number is Prime"); else printf("\nThe Number is Not Prime"); } printf("\nPress any key to continue..."); getch(); }   Output Enter any positive integer number to check 4 The Number is Not Prime Press any key to continue... Enter any positive integer number to check 7 The Number is Prime Press any key to continue...

Program for calculating Simple Interest using the concept of Default Arguments

//Program for Interest calculation using the concept of default arguments #include<iostream.h> #include<conio.h> void main() { float amount, principal; int time; float interest(float p, int n, float r=0.15); cout<<"Program for simple interest calculation"<<endl; cout<<"Please enter principal amount:"; cin>>principal; cout<<"Please enter Time: "; cin>>time; amount=interest(principal, time); cout<<"\nThe amount is:"<<amount; cout<<"\nPress any key to continue..."; getch(); } float interest(float p, int n,float r) { return (p+((p*r*n)/100.0)); }

Menu Driven Program for Area of various figures in C++

#include<iostream.h> #include<conio.h> #include<process.h> #include<math.h> float area(float); float area(float,float); float area(float,float,float); void main() { float a,b,c,s,ar; int ch; clrscr(); while(1) { cout<<"\nYou can chose from the following options:"<<endl; cout<<"Press 1: Area of Square"<<endl; cout<<"Press 2: Area of Rectangle"<<endl; cout<<"Preaa 3: Area of Triangle"<<endl; cout<<"Press 4: Exit"<<endl; cout<<"Please Enter Your choice(1-4):"; cin>>ch; switch (ch) { case 1: cout<<"Please Enter the Side of the Square:"; cin>>a; ar=area(a); break; case 2: cout<<"Please enter the Length and Breadth of the Rectangle:"; cin>>a>>b; ar=area(a,b); break; case 3: cout<<"Please enter three sides of the Triangle:"; cin>>a>

Program for Area calculation in C++

#include<iostream.h> #include<conio.h> class shape { float circle; float rect; public: shape() { circle=0; rect=0; } void area(float r) { circle=(3.14*r*r); cout<<circle; } void area(float h, float l) { rect=h*l; cout<<"\nThe area of rectangle is:"<<rect; } }; void main() { shape s1; int ch; float he,le,re; clrscr(); cout<<"****************************************************\n"; do { cout<<"\nTo calculate area of rectangle press    1 : \nTo calculate area of circle press     2 : \nTo exit from program please press     3 :\n"; cout<<"\nPlease Enter Your Choice:"; cin>>ch; switch(ch) { case 1: cout<<"Enter Hieght and length to calculate are of rectangle :\n"; cin>>he>>le; s1.area(he,le); break; case 2: cout<<"\nEnter radious to calculate are of circle :\n"; cin>>re; s1.area(re); break; } } while(c

Program for Checking whether the given number is Palindrome or not

Palindrome means a number which remains same if positions of its digits is reversed i.e., 1221 #include<stdio.h> #include<conio.h> void main() { int n,digit,rev=0,num; printf("enter the number"); scanf("%d",&num); n=num; do { digit=num%10; rev=rev*10+digit; num/=10; }while(num!=0); printf("reverse number is=%d\n",rev); if(n==rev) { printf("number is palindrome"); } else { printf("number is not palindrome") ; } getch(); }

Program for Ellipse Generation Using Bresenham's Algorithm in C++

//Program to implement Ellipse Drawing Algorithm #include<iostream.h> #include<graphics.h> #include<conio.h> #include<math.h> #include<dos.h> #include<stdlib.h> #include<stdio.h> class myCircle     {     private:     int x,y,r,d,x1,y1,minor,major,dtheta,ratio,a,b,x2,y2;     public:     myCircle();      //Constructor     void showCircle();     }; myCircle::myCircle()         {         x=0;y=0;         cout<<"     "Enter The Major & Minor Axis Of Ellipse ":=";         cin>>major>>minor;         cout<<"     "Enter The Center Of The Ellipse ":=";         cin>>x>>y;         } void myCircle::showCircle()         {         char *s;                 int ax,ay;                 float ar;                 x1=1;                 ratio=major/minor;                 getaspectratio(&ax,&ay);         ar=1;         while(x1<=major)    

Introduction to Computer Graphics

Computer Graphics Computer Graphics:- Computer Graphics is a sub field of computer science and is concerned with visual content till recently the   output obtained from a computer has been alpha numeric. It is well known that information presented in Graphical and pictorial form tremendously helps human comprehension. For example , Bar charts, Pie charts, Sales Graphs, etc. Are commonly use by managers. Building plans, perspective views , card board models etc. Are used by architects , Engineers use mechanical drawings., Circuit diagrams, etc. In their work. Computer Graphics is concerned with the generation, representation, Manipulation and display of pictures with the help of Computer. With emergence of Graphical user Interface (GUI) Computer Graphics has become an integral part of all computers today. Branches of Computer Graphics:- Modeling: - Modeling describes the shake of an object. Be cause the appearance of an object depends largely on the exterior of the object, bound