C++

Program to change the background colors 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...
>>

Program to draw circles

#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...
>>

Program to draw 2 rectangles and fill 1 of them

#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,...
>>

Program to enter an integer and print out its successor

#include <iostream.h> #include <conio.h> void value(int); void main() { clrscr(); int x; cout << "Enter an integer : "; cin>>x; cout << "The successor of " << x << " is "; value(x); getch(); } void value(int x) { x++; cout << x << "." <<...
>>

Program to enter an integer and output the cube of that integer

#include <iostream.h> #include <conio.h> int cube(int x); //The prototype. void main() { clrscr(); int a; cout << "Enter an integer : "; cin>>a; cout << "The cube of " << a << " is : " << cube(a) << endl; //Call the function cube(a). getch(); } //Defining...
>>

Program to enter a string and find its length

#include <iostream.h> #include <conio.h> #include <string.h> void main() { clrscr(); int slength; char x[81]; //Allowing the user to input a maximum of 80 characters. cout << "Enter the string : " << endl; cin>>x; slength=strlen(x); cout << "The length of the string "...
>>

Program to enter an integer and print if it is prime or composite

#include <iostream.h> #include <conio.h> #include <process.h> void main() { clrscr(); int num1,x; cout << "Enter an integer : " << endl; cin>>num1; for(x=2;x<num1;x++) { if(num1%x==0) { cout << num1 << " is a composite number." <<...
>>

Program to enter the principal, rate & time and print the simple interest

#include <iostream.h> #include <conio.h> void main() { clrscr(); int x; float sinterest,principal,rate,time; for(x=4;x>=0;x--) { cout << "Enter the principal, rate & time : " << endl; cin>>principal>>rate>>time; sinterest=(principal*rate*time)/100; cout << "Principal =...
>>

Program to switch between different cases

#include <iostream.h> #include <conio.h> int main() { clrscr(); int choice; cout << "1. Talk" << endl; cout << "2. Eat" << endl; cout << "3. Play" << endl; cout << "4. Sleep" << endl; cout << "Enter your choice : " <<...
>>

Program to enter the sale value and print the agent's commission

#include <iostream.h> #include <conio.h> void main() { clrscr(); long int svalue; float commission; cout << "Enter the total sale value : " << endl; cin>>svalue; if(svalue<=10000) { commission=svalue*5/100; cout << "For a total sale value of $" << svalue <<...
>>
<< 1 | 2 | 3 | 4 | 5 >>

Search site

Copyright © 2012 Dadaso Zanzane. All rights reserved.