Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
52Activity
0 of .
Results for:
No results containing your search query
P. 1
C++ Short Example Programs

C++ Short Example Programs

Ratings: (0)|Views: 3,740|Likes:
This contains 20 C++ programs of 12th
standard, which I had submitted to the CISCE.
If you are searching for some brainstorming
stuffs, with all outputs and variable listing, for
your C++ project then your search ends here.
You can also download my free Sudoku Solver
and Calendar bundled together as Utility from:
http://sharecash.org/download.php?file=106116
Check it out...
This contains 20 C++ programs of 12th
standard, which I had submitted to the CISCE.
If you are searching for some brainstorming
stuffs, with all outputs and variable listing, for
your C++ project then your search ends here.
You can also download my free Sudoku Solver
and Calendar bundled together as Utility from:
http://sharecash.org/download.php?file=106116
Check it out...

More info:

Published by: humayun kabir sarkar on Sep 21, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/04/2013

pdf

text

original

 
 1
Dart
The DART is a fun program which randomly generates an invisible dart and
allows you to enter a shot. If you hit the centre you hit the “bull’s eye”!
 
#include<iostream.h>#include<math.h>#include<stdlib.h>#include<stdio.h>#include<conio.h>voidmain(){for(;;){clrscr();intr=(random(5)+2)*2-1;intc=(random(5)+2)*2-1;inta,b;chardart[15][15];cout<<"\nA NEW DART IS READY!!\n";cout<<"ENTER A SHOT---->\n";cout<<"INPUT ROW NO.:";cin>>a;cout<<"INPUT COLUMN NO.:";cin>>b;if(a==(r+1)/2 && b==(c+1)/2){cout<<"BULLS EYE!!\n";}else if(a>r || b>c) {cout<<"OUT OF DART\n";}else{cout<<"BAD SHOT\n";}for(inti=0;i<r;i++) {for(intj=0;j<c;j++) {if(!(j==b-1 && i==a-1))cout<<"*";elsecout<<" ";}cout<<"\n";}getch();}}
 
 2
Algorithm
1.
 
A dart of random dimensions is created (
dart[ ][ ]
) ranging from 3-11 oddnumbers2.
 
The user is allowed to input the coordinates of the target point.3.
 
If the coordinates match the centre of the dart the program prints “bull’s eye” and
other messages for an unsuccessful shot.4.
 
The dart is finally printed with the missing point where the dart is shot.
Output
A NEW DART IS READY!!ENTER A SHOT ---- >INPUT ROW NO.:3INPUT COLUMN NO.:4OUT OF DART*********A NEW DART IS READY!!ENTER A SHOT ---- >INPUT ROW NO.:4INPUT COLUMN NO.:5BULL'S EYE!!******************
 
*********
 
*********
 
**** ****
 
*********
 
*********
 
*********
 
*********
 
*********
 
Variable Listing
VARIABLE TYPE
 
SCOPE
 
DESCRIPTION
 
r int main() stores random numbers from 3-11c int main() stores random odd numbers from 3-11a int main() takes row input from userb int main() takes column input from userdart int[ ][ ] main() ----------------------------------------i int main() iterative variablej int main() 2
nd
iterative variable
 
 3
Date
The DATE program asks for a date input in the general date format (dd/mm/yyyy). It then asks for the first weekday of the year and gives the weekday for the entered date
(“A pretty simple program!”).
 
#include<iostream.h>#include<conio.h>#include<stdlib.h>#include<stdio.h>#include<string.h>#include<ctype.h>//--------------------------------------------------------------------------intdate[]={31,0,31,30,31,30,31,31,30,31,30,31};char days[][10]={"sunday","monday","tuesday","wednesday","thursday","friday","saturday"}; //==========================================================================voidmain(){clrscr();intisLeap(int); cout<<"Enter today's Date: ";char* d,temp[10];cin>>d;d[strlen(d)]='/';//[1] intday,month,year;//--------------------------------------------------------------------------strset(temp,'\0');//[2] for(inti=0,count=1;i<strlen(d);i++) {if(!isdigit(d[i])){if(count==1)day=atoi(temp);if(count==2)month=atoi(temp);if(count==3)year=atoi(temp);count++;strset(temp,'\0');}elsetemp[strlen(temp)]=d[i];}//--------------------------------------------------------------------------if(isLeap(year))//[3]date[1]=29;elsedate[1]=28;//--------------------------------------------------------------------------cout<<"Enter the weekday of 1st January of this year: ";cin>>d;//--------------------------------------------------------------------------intsumd=0;//[4]

Activity (52)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Saeed Bawazir liked this
Kalanidhi liked this
Jojo Cansino liked this
love2390 liked this
horror21 liked this
horror21 liked this
Xmatrix Lee liked this
manjunathp079030 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->