Program to draw 2 rectangles and fill 1 of them in cpp

  #include <iostream.h> #include <conio.h> #include <graphics.h> #include <ctype.h> #include <stdlib.h> #include <stdio.h> void main() { clrscr(); int gd = DETECT,gm,errorcode; //Requesting auto-detection. //Initializing graphics and local variables. initgraph (&gd, &gm, “d:\bc3\bgi”); //Path where graphics drivers are installed //Read result of initialization. errorcode = graphresult(); //An error occured. if (errorcode != grOk) { cout << … Read more

Program to change the foreground colors and draw circles on the screen

  #include <conio.h> #include <graphics.h> #include <stdlib.h> #include <stdio.h> void main (int) { int gdriver=DETECT,gmode,errorcode; //Requesting auto-detection. int midx,midy,x; //Initializing graphics and local variables. initgraph(&gdriver,&gmode,“d:\bc3\bgi”); //Reading result of initialization. errorcode=graphresult(); if(errorcode!=grOk) //An error occurred. { printf(“Graphics error occurred : %s \n”,grapherrormsg(errorcode)); printf(“Press any key to stop : “); getch(); exit(1); //Terminate the program due to … Read more

Program to enter an integer and find out if it is even or odd

#include <iostream.h> #include <conio.h> void main() { clrscr(); int x; cout << “Enter an integer : “; cin>>x; if(x%2==0) cout << “The number ” << x << ” is even.”; else cout << “The number ” << x << ” is odd.”; getch(); }   This program takes in an integer x as a screen … Read more

Program to enter two integers and print the quotient and remainder

#include <iostream.h> #include <conio.h> int main() { clrscr(); int x,y,quotient,remainder; cout << “Enter 2 integers greater than 0 : “; cin>>x>>y; quotient=x/y; remainder=x-(quotient*y); cout << “Quotient of ” << x << ” & ” << y << ” = ” << quotient << “\n”; cout << “Remainder” << ” = ” << remainder << “\n”; … Read more

Program to enter an integer and output its 15 multiples

  #include <iostream.h> #include <conio.h> int main() { clrscr(); int x; cout << “Enter an integer less than 2185 : “; cin>>x; cout << “The first 15 multiples of ” << x << ” are : “; for(int y=1;y<16;y++) cout << “\n” << x << “x” << y << “=” << x*y; getch(); return 0; … Read more

Program to enter your age and print if you should be in grade 10

  #include <iostream.h> #include <conio.h> void main() { clrscr(); int age; cout << “Enter your present age : ” << endl; cin>>age; if(age==16) { cout << “Your present age is ” << age << ” years.” << endl; cout << “You are of the right age for joining grade 10 !” << endl; } else … Read more

Program to enter two integers and find their sum and average

#include <iostream.h> #include <iostream.h> #include <conio.h> void main() { clrscr(); int x,y,sum; float average; cout << “Enter 2 integers : ” << endl; cin>>x>>y; sum=x+y; average=sum/2; cout << “The sum of ” << x << ” and ” << y << ” is ” << sum << “.” << endl; cout << “The average of … Read more