
| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:46:57 IST
|
|
|
#include<fstream.h> #include<conio.h> #include<stdio.h> #include<string.h> #include<process.h> char arr[30];
void main() { clrscr();
int ch; char y;
do { cout<<"\n\n$$$$$$$$$$$menu$$$$$$$$$$"; cout<<"\n\n1.Enter the strings"; cout<<"\n\n2.To see the details"; cout<<"\n\n3.Exit"; cout<<"\n\nPlease enter the details"; cin>>ch;
if(ch==3) { exit(0); }
if(ch==1) {
for(int i=0;i<2;i++) { if(i%2==0) {
cout<<"Enter the line"; gets(arr); fstream fin("even line.txt",ios::app|ios::in); for(int i=0;i<30;i++) { fin<<arr[i]<<"\n"; } } else if(i%2!=0) {
cout<<"Enter the line"; gets(arr); fstream fout("odd line.txt",ios::app|ios::in); for(i=0;i<30;i++) { fout<<arr[i]<<"\n"; } } } } if(ch==2) { char ch;
cout<<"\n\nEnter file you want to view even(y\n)"; cin>>ch;
if(ch=='y')
{ fstream fout1("even line.txt",ios::app|ios::in); for(int i=0;i<30;i++) { fout1>>arr[i]; } puts(arr);
}
else { fstream fout2("odd line.txt",ios::app|ios::in); for(int i=0;i<30;i++) { fout2>>arr; } puts(arr);
} }
cout<<"\n\nDo you want to continue"; cin>>y;
}while(y=='y');
getch();
}
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:47:29 IST
|
|
|
/* Color full lights */
#include<iostream.h> #include<stdio.h> #include<conio.h> #include<graphics.h> #include<stdlib.h> #include<math.h> void main() { int r,count,c,x,y,angle; int a = DETECT,b; initgraph(&a,&b,"\\tc\\bgi"); x = getmaxx(); y = getmaxy();
cout << "\n1.Blue \n2.Green\n3.Cyan\n4.Red\n5.Magentha\n6.Orange"; cout << "\nENTER A COLOR : "; cin >> c; while(!kbhit()) { for(count = 1;count <= 200;count++) { for(angle = 1;angle <= 360 ; angle++) { r = count + count * sin(angle); x = 320 + r * cos(angle); y = 50 + r * sin(angle); putpixel(x - 20,y + 20,c); } } for(count = 1;count <= 200;count++) { for(angle = 1; angle <= 360;angle++) { r = count + count * sin(angle); x = 320 + r * cos(angle); y = 50 + r * sin(angle); putpixel(x - 20,y + 20,BLACK); } } } getch(); closegraph(); }
|
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:48:11 IST
|
|
|
#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<stdlib.h> int x=0; class worker { char name[10]; int hrs; int wage_rate; int total_wage; public: void get_data(); void put_data(); void insert(int); void delete_record(int); }A[10]; void worker :: get_data() { cout<<"\n\nEntering data"; cout<<"\n-------------"; cout<<"\n\nEnter workers name:: "; gets(name); cout<<"\nEnter hours worked:: "; cin>>hrs; cout<<"\nEnter the wage rate:: "; cin>>wage_rate; total_wage = (hrs * wage_rate); cout<<"\nTotal wage is:: "<<total_wage; } void worker :: put_data() { cout<<"\n\n\nDisplaying data"; cout<<"\n--------------"; cout<<"\n\nWorkers name:: "; puts(name); cout<<"\nHours worked:: "<<hrs; cout<<"\n\nWage rate:: "<<wage_rate; cout<<"\n\nTotal wage:: "<<total_wage; } void worker :: insert(int a) { for(int i=x;i>=a;i--) { A[i]=A[i-1]; } A[a].get_data(); x=x+1; }
void worker :: delete_record(int b) { for(int i=b;i<x;i++) { A[i]=A[i+1]; } cout<<"\n\nRecord deleted"; x=x-1; }
void main() { clrscr(); char ch; cout<<" WORKER\n"; cout<<" ------"; cout<<"\n\nEnter the number of persons:: "; cin>>x; do { int n; cout<<"\n\nMenu"; cout<<"\n----"; cout<<"\n\n1.Enter data"; cout<<"\n\n2.Display data"; cout<<"\n\n3.Insert record"; cout<<"\n\n4.Delete record"; cout<<"\n\n5.Exit"; cout<<"\n\n\nEnter your choice:: "; cin>>n; if(n==1) { clrscr(); for(int i=0;i<x;i++) A[i].get_data(); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==2) { clrscr(); for(int i=0;i<x;i++) A[i].put_data(); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==3) { clrscr(); cout<<"\n\nInserting Record"; cout<<"\n-----------------"; int m; cout<<"\n\nEnter the position:: "; cin>>m; A[m-1].insert(m-1); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==4) { clrscr(); cout<<"\n\nDeleting Record"; cout<<"\n----------------"; int p; cout<<"Enter the position:: "; cin>>p; A[p-1].delete_record(p-1); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==5) { exit(0); } }while(ch=='y'); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:50:17 IST
|
|
|
#include <stdio.h> #include <iostream.h> #include <stdlib.h> #include <values.h> #include <time.h> #include <string.h>
const int max=1000; int list[max]; FILE *fp;
void insertion(int aa[],int max1) { int a,b,v;
for(a=1;a<max1;a++) { v = aa[a]; b = a; while(aa[b-1] > v) { aa[b] = aa[b-1]; b = b - 1; } aa[b] = v; } }
void quicksort(int min1,int max2) { int t;
if (max2 > min1) { int v = list[max2]; int i = min1 - 1; int j = max2; do { do { i = i + 1; } while (list[i] < v); do { j = j - 1; } while (list[j] > v); int t = list[i]; list[i] = list[j]; list[j] = t; } while (j > i); list[j] = list[i]; list[i] = list[max2]; list[max2] = t; quicksort(min1,i-1); quicksort(i+1,max2); } }
void main() {
int i,j,k,l; char any1[8],any2[8];
cout << "Enter a file name\n"; cin >> any1; /*if(strlen(any1) > 12) cout << "File name input error."; */
fp = fopen(any1,"wb"); for(j=0;j<30000;j++) { k = rand(); fprintf(fp,"%d\n",k); } fclose(fp); fp = fopen(any1,"rb"); i = 0; while (fscanf(fp,"%d\n",l) != 0) { list[i] = l; i = i + 1; } fclose(fp);
/*int min = 0; quicksort(min,max); */ insertion(list,max);
cout << "Enter an output file : "; cin >> any2; fp = fopen(any2,"wb"); for(i=0;i<max;i++) { int r = list[i]; fwrite(&r,sizeof(int),1,fp); } fclose(fp); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 15 points
(with 3 
in 3 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:50:36 IST
|
|
|
#include <stdio.h> #include <iostream.h> #include <stdlib.h> #include <values.h> #include <time.h> #include <string.h>
const int max=1000; int list[max]; FILE *fp;
void insertion(int aa[],int max1) { int a,b,v;
for(a=1;a<max1;a++) { v = aa[a]; b = a; while(aa[b-1] > v) { aa[b] = aa[b-1]; b = b - 1; } aa[b] = v; } }
void quicksort(int min1,int max2) { int t;
if (max2 > min1) { int v = list[max2]; int i = min1 - 1; int j = max2; do { do { i = i + 1; } while (list[i] < v); do { j = j - 1; } while (list[j] > v); int t = list[i]; list[i] = list[j]; list[j] = t; } while (j > i); list[j] = list[i]; list[i] = list[max2]; list[max2] = t; quicksort(min1,i-1); quicksort(i+1,max2); } }
void main() {
int i,j,k,l; char any1[8],any2[8];
cout << "Enter a file name "; cin >> any1; /*if(strlen(any1) > 12) cout << "File name input error."; */
fp = fopen(any1,"wb"); for(j=0;j<30000;j++) { k = rand(); fprintf(fp,"%d ",k); } fclose(fp); fp = fopen(any1,"rb"); i = 0; while (fscanf(fp,"%d ",l) != 0) { list[i] = l; i = i + 1; } fclose(fp);
/*int min = 0; quicksort(min,max); */ insertion(list,max);
cout << "Enter an output file : "; cin >> any2; fp = fopen(any2,"wb"); for(i=0;i<max;i++) { int r = list[i]; fwrite(&r,sizeof(int),1,fp); } fclose(fp); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:51:36 IST
|
|
|
#if !defined( __TIMER_H ) #define __TIMER_H
#if defined( _Windows ) && !defined( _BUILDRTLDLL ) #error Timer not available for Windows #endif
#if !defined( __DEFS_H ) #include <_defs.h> #endif
class Timer {
public:
Timer();
void start(); void stop(); void reset();
int status(); double time();
static double resolution();
private:
static unsigned adjust; static unsigned calibrate(); int running;
struct TIME { unsigned long dosCount; unsigned timerCount; };
TIME startTime;
double time_;
};
inline int Timer::status() { return running; }
inline double Timer::time() { return time_/1.E6; }
inline double Timer::resolution() { return 839/1.E9; }
#endif // __TIMER_H
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:53:56 IST
|
|
|
/* Cricket Score Analysis */
#include<stdio.h> #include<conio.h> void main() { clrscr(); int s1,s2,c,w1,w2,d,p; char a[12],b[12]; printf(" Come on let us analysis cricket scores"); printf("\n\nEnter the first team : "); scanf("%s",a); printf("\nEnter the second team : "); scanf("%s",b); printf("\nEnter the score of %s :",a); scanf("%d",&s1); printf("\nEnter the score of %s :",b); scanf("%d",&s2); printf("\nEnter the type of pitch :\n1.Batting\n2.Bowling "); scanf("%d",p); printf("\nEnter the no of wickets gone for %s : ",a); scanf("%d",w1); printf("\nEnter the no of wickets gone for %s : ",b); scanf("%d",w2); if(p == 1); if(s1>s2) c = s1 - s2; printf("\n\n\n Let us see about the batting of %s",a); printf("\n\nBy seeing the difference %d in scores.....",c); if(c < 40) printf("\n\nThe batting of %s is good in this pitch",a); printf("\n\nThe batting of %s is also better in this pitch",b); if(c > 39) printf("\n\nthe batting order is not good for %s",b); printf("\n\nthe batting order is well planned for %s",a); if(s2>s1) c = s2 - s1; printf("\n\n\n Let us see about the batting of %s",b); printf("\n\nBy seeing the difference %d.....",c); if(c < 40) printf("\n\nThe batting of %s is good in this pitch",b); printf("\n\nThe batting of %s is also better in this pitch",a); if(c >39) printf("\n\nthe batting order is not good for %s",a); printf("\n\nthe batting order is well planned for %s",b); if(p == 2) if(w1 > w2) d = w1 - w2; printf("\n\n\n Let us see about the bowling of %s",a); if(d < 4) printf("\n\nThe team %s has to bowl well",b); printf("\n\nThe team %s has to concentrate more in bowling",a); if(d > 3) printf("\n\nThe team %s has bowled very well",b); printf("\n\nSpinners has to take chance in %s",a); if(w2 > w1) d = w2 - w1; printf("\n\n\n Let us see about the bowling of %s",b); if(d < 4) printf("\n\nThe team %s has to bowl well",a); printf("\n\nThe team %s has to concentrate more in bowling",b); if(d > 3); printf("\n\nThe team %s has bowled very well",a); printf("\n\nSpinners has to take chance in %s",b); getch(); }
|
|
this reply: 15 points
(with 3 
in 3 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:56:08 IST
|
|
|
/* Function for constructing a trapezium */
#include<stdio.h> #include<conio.h> #include<graphics.h> void trapeiz(int x1,int y1,int x2,int y2,int r) {
line(x1,y1,x1-r,y2-r); line(x1-r,y2-r,x2+r,y2-r); line(x2+r,y2-r,x2,y1); line(x2,y1,x1,y1);
} void main() { int gd = DETECT,gm,x,y,x1,y1,x2,y2,r; initgraph(&gd,&gm,"c:\\tc\\bgi"); x = getmaxx(); y = getmaxy(); printf("Enter the first x - coordinate : "); scanf("%d",&x1); printf("Enter the first y - coordinate : "); scanf("%d",&y1); printf("Enter the second x - coordinate : "); scanf("%d",&x2); printf("Enter the second y - coordinate : "); scanf("%d",&y2); printf("Enter the Extension of trapezium : "); scanf("%d",&r); clrscr(); trapeiz(x1,y1,x2,y2,r); getch(); closegraph(); }
|
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 14:05:33 IST
|
|
|
Thanks , GOIITians for starting this posts for C++, I am in XI and i have comp exam day after tomorrow. Can anyone tell me that how to have the command prompt in full screen , i have vista I tried all options but I am not getting full screen to work on.plz tel me
|
We should care for our environment, It is the time to save all the natural resources which we r using in our daily life. WE HAVE TO SAVE OUR PLANET EARTH.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 17:04:33 IST
|
|
|
I had vista and had the same problem too.I asked my uncle who is a software engineer and he could't solve it.Therefore I switched to XP back again.
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 20 Feb 2008 15:43:07 IST
|
|
| |