Monday, May 24, 2010

Write a c program that will generate an arbitrary number of integers and store them in the file name numfile?

the c program one integer per line

Write a c program that will generate an arbitrary number of integers and store them in the file name numfile?
#include %26lt;stdio.h%26gt;


#include %26lt;stdlib.h%26gt;





int


main(int argc, char* argv[])


{


  int count = argc%26gt;1 ? atoi(argv[1]) : 10;


  FILE *f = fopen("numfile", "w+");


  if (!f)


    perror("fopen"), exit(-1);


  for (int i=0; i%26lt;count; i++)


    fprintf(f, "%d\n", rand());


  fclose(f);


  return 0;


}


Write a C++ Program that prints the block letter "B" IN A 7 x 6 grid of stars?

NOTE


using a C++ PROGRAM PLEASE!!

Write a C++ Program that prints the block letter "B" IN A 7 x 6 grid of stars?
Trisha,





As someone who teaches programming, I can tell you that this approach to homework is only going to hurt yourself (and probably cause you to fail the course).





All the concepts you're covering in class build upon one another... so if you don't learn to do this week's homework, you won't be able to do any of the following weeks' homework (not to mention tests and larger-scale projects).
Reply:I am really sorry to say. But try it on your own, if it is a project given to you. The hint is "Use for loop".
Reply:Do your own homework!


I have a doubt in c++ program?

i have an error in c++ program.......its coming as an error 4 all the programs......the error is "fatal..\INCLUDE\CONIO%26gt;H 165: error directive: must use c++ for the type iostream". so wat correction am i supposed to make?

I have a doubt in c++ program?
I think you wrote a program as C++, but saved the file as a C file. For example, instead of naming the file MyProg.cpp, you called it MyProg.c. The compiler uses the file extension to determine if the program is a C program or a C++ program.
Reply:it is the error of your header files......either your library is corrupter or you need to set ur path by going in DOS shell.........
Reply:I wish you had provided your code because this looks like a relatively simple problem but wihtout your code it can be many types of things but one thing is for certain, thre previous responder (above this comment) is wrong in saying the file could be corrupt (that is just silly).....





Could you paste your code so i can take a look? Also it might be possible that your dev environment is set up to think its C specific or C++ (depending on which type you are trying to compile in)..





you should have either (or both):





#include %26lt;conio%26gt;


#include %26lt;iostream%26gt;





Notice you dont need to mention the ".h" extension for the conio portion if you are working with C++ code....And notice i didn't give the path to the library...the system knows where theya re already.


A program on a General tree having more than 2 child node in Data structure in C programming?

a C program on a General tree having more than 2 child node in Data structure in C programming. it is not a binary tree, but it should be a general tree where root node have three child node and each child node have three sub child node. want a help program on that

A program on a General tree having more than 2 child node in Data structure in C programming?
do you know how to implement double linked list ? please learn how to implement double linked list. this will solve your problem

umbrella plant

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?
Cool. I think it is like taping into the state of the equation and filling the history


Write a c program to merge sort 2 already sorted arrays?

how do i write a c program to merge sort 2 already sorted arrays?

Write a c program to merge sort 2 already sorted arrays?
Here is a small programme that will merge two sorted arrays of integer. You'll have to tweek it if you want to merge a different numeric type, and to add error checking -- I left all error checking out to make the code clearer.





#include %26lt;stdlib.h%26gt;





int *merge( int *a, int *b, int len )


{


int ai = 0; /* index into each array */


int bi = 0;


int *m = NULL;


int *mp = NULL;





mp = m = (int *) malloc( sizeof( int ) * len * 2); /* merged result*/





while( ai %26lt; len %26amp;%26amp; bi %26lt; len ) /* until one source is exhausted*/


{


if( *(a+ai) %26lt; *(b+bi) )


*mp++ = *(a+ai++);


else


*mp++ = *(b+bi++);


}





/* tack on the remainder of the array that was not exhausted */


while( ai %26lt; len )


*mp++ = *(a+ai++ );


while( bi %26lt; len )


*mp++ = *(b+bi++ );





return m; /* the merged array goes back to caller */


}








main( int argc, char **argv )


{


int first[] = { 1, 4, 8, 10, 12, 16, 22 };


int second[] = { 3, 6, 9, 12, 15, 18, 21 };


int *merged;


int i;





merged = merge( first, second, 7 );


for( i = 0; i %26lt; 14; i++ )


printf( "%d ", merged[i] );


printf( "\n" );


}


Write a c program to simulate the movement of a caer?

The program should in C lanaguage and also related to Graphics designing.

Write a c program to simulate the movement of a caer?
I have this program on boat race. Take logic and have it as you desire.


#include%26lt;graphics.h%26gt;


#include%26lt;stdio.h%26gt;


#include%26lt;dos.h%26gt;


#include%26lt;math.h%26gt;


int b1,b2,b3,b4,b5,b6,j1=0,i1=0,i=DETECT,j,k...


FILE *fp;


char name[15];


void hai(int,int);


void main()


{


if(fopen("scores.txt","r")==NULL)


{


fp=fopen("scores.txt","w");


fprintf(fp,"0 0 0 0 0 0");


}


initgraph(%26amp;i,%26amp;j,"c:\\tc\\bgi");


setcolor(5);


settextstyle(1,0,6);


outtextxy(40,150,"welcome to boat race");


outtextxy(40,174,"----------------");


getch();


textmode(0);


textcolor(2);


cprintf("enter your name::");


cscanf("%s",%26amp;name);


printf("\n\n");


cprintf(" hai %s welcome to boat race",name);


printf("\n\n\n");


textcolor(14);


cprintf(" records of boats");


table();


printf("\n\n\n\n");


cprintf("see records and select a boat");


printf("\n\n");


cprintf("enter the boat no.::");


cscanf("%d",%26amp;n);


getch();


i=0;


initgraph(%26amp;i,%26amp;j,"c:\\tc\\bgi");


setcolor(14);


rectangle(1,1,getmaxx(),getmaxy());


rectangle(7,7,getmaxx()-7,getmaxy()-7)...


setfillstyle(1,2);


floodfill(6,6,14);


settextstyle(7,0,3);


outtextxy(23,23,"enter any key to start the game. . . . . . . . .");


while(j1!=1)


{i1++;


if(kbhit())


j1=1;}


getch();


j1=abs(i1);


setcolor(0);


settextstyle(7,0,3);


outtextxy(23,23,"enter any key to start the game. . . . . . . . .");


setcolor(15);


circle(500,55,30);


setfillstyle(1,14);


floodfill(500,55,15);


for(i=0;i%26lt;550;i++)


hai(i,j1);


getch();}


void hai(int i,int j1)


{int l;


for(j=0;j%26lt;251;j+=50)


{if(j==0)


{if((b1%26gt;180%26amp;%26amp;b1%26lt;240))


b1+=1;


else if(b1%26gt;250%26amp;%26amp;b1%26lt;400)


b1+=3;


else if((j1%8)%2==0)


b1+=(j1%8+1);


else


b1+=(j1%8);


i=b1;}


else if(j==50)


{if(b2%26gt;100%26amp;%26amp;b2%26lt;200)


b2+=5;


else if(b2%26gt;300%26amp;%26amp;b2%26lt;400)


b2+=5;


else if((j1%3)%2==0)


b2+=(j1%3+1);


else


b2+=j1%3;


i=b2;}


else if(j==100)


{if(b3%26gt;100%26amp;%26amp;b3%26lt;150)


b3+=3;


else if(b3%26gt;150%26amp;%26amp;b3%26lt;300)


b3+=5;


else if((j1%4)%2==0)


b3+=(j1%4+1);


else


b3+=j1%4;


i=b3;}


else if(j==150)


{if(b4%26gt;100%26amp;%26amp;b4%26lt;200)


b4+=3;


else if(b4%26gt;300%26amp;%26amp;b4%26lt;400)


b4+=3;


else if((j1%5)%2==0)


b4+=(j1%5+1);


else


b4+=j1%5;


i=b4;}


else if(j==200)


{if(b1%26gt;200%26amp;%26amp;b4%26lt;400)


b5+=3;


else if(b2%26gt;100%26amp;%26amp;b3%26lt;200)


b5+=3;


else if((j1%6)%2==0)


b5+=(j1%6+1);


else


b5+=j1%6;


i=b5;}


else if(j==250)


{if(b2%26gt;50%26amp;%26amp;b3%26lt;300)


b6+=1;


else if(b1%26gt;150%26amp;%26amp;b4%26lt;300)


b6+=3;


else if((j1%7)%2==0)


b6+=(j1%7+1);


else


b6+=j1%7;


i=b6;}


setcolor(2);


line(8,180+j,630,180+j);


setcolor(6);


ellipse(40+i,159+j,180,360,30,20);


setcolor(7);


circle(35+i,159+j,4);


arc(42+i,164+j,180,310,10);


if(i%2==0)


{line(35+i,167+j,48+i,174+j);


line(38+i,167+j,50+i,174+j);


setcolor(14);


line(50+i,170+j,40+i,200+j);}


else


{line(38+i,167+j,30+i,179+j);


line(35+i,167+j,28+i,180+j);


setcolor(14);


line(31+i,170+j,21+i,200+j);}


if(i%26gt;550%26amp;%26amp;i%26lt;560)


{l=10;


k=j;}}


if(l==10)


{setcolor(6);


fp=fopen("scores.txt","r+");


settextstyle(1,0,4);


switch(k/50+1)


{case 1:


outtextxy(30,230,"the winner of the game is 1st boat");


break;


case 2:


outtextxy(30,230,"the winner of the game is 2th boat");


break;


case 3:


outtextxy(30,230,"the winner of the game is 3th boat");


break;


case 4:


outtextxy(30,230,"the winner of the game is 4th boat");


break;


case 5:


outtextxy(30,230,"the winner of the game is 5th boat");


break;


case 6:


outtextxy(30,230,"the winner of the game is 6th boat");


}


if(n==(k/50+1))


outtextxy(30,270,"congrats ! you have won the match");


else


outtextxy(30,270,"sorry ! you have lost the match");


fseek(fp,(k/50)*12,0);


fscanf(fp,"%d",%26amp;c);


c+=1;


if(c%26gt;=10)


c=0;


fseek(fp,(k/50)*12,0);


fprintf(fp,"%d",c);


fclose(fp);


getch();


cleardevice();


exit(0);}


for(k=0;k%26lt;4;k++)


delay(2000000);


for(j=0;j%26lt;251;j+=50)


{if(j==0)


i=b1;


else if(j==50)


i=b2;


else if(j==100)


i=b3;


else if(j==150)


i=b4;


else if(j==200)


i=b5;


else if(j==250)


i=b6;


setcolor(0);


ellipse(40+i,159+j,180,360,30,20);


circle(35+i,159+j,4);


arc(42+i,164+j,180,310,10);


if(i%2==0)


{line(35+i,167+j,48+i,174+j);


line(38+i,167+j,50+i,174+j);


line(50+i,170+j,40+i,200+j);}


else


{line(38+i,167+j,30+i,179+j);


line(35+i,167+j,28+i,180+j);


line(31+i,170+j,21+i,200+j);}}}


table()


{


fp=fopen("scores.txt","r+");


for(j=0;j%26lt;7;j++)


for(i=10;i%26lt;15;i++)


{gotoxy(4+j*5,i);


cprintf("%c",'³');}


for(j=9;j%26lt;=15;j+=3)


for(i=4;i%26lt;35;i++)


{gotoxy(i,j);


cprintf("%c",'Ä');}


for(i=0;i%26lt;7;i+=3)


for(j=0;j%26lt;7;j++)


{gotoxy(4+j*5,9+i);


if(j==0)


cprintf("%c",'Ã');


else if(j==6)


cprintf("%c",'´');


else


cprintf("%c",'Å');}


for(i=0;i%26lt;6;i++)


{gotoxy(5+i*5,10);


printf("boat");


gotoxy(6+i*5,11);


printf("%d",i+1);


fseek(fp,i*12,0);


fscanf(fp,"%d",%26amp;c);


gotoxy(6+i*5,13);


printf("%d",c);}


getch();


}





visit us :: ebizwebbiz.com/mahesh_naidu/


ebizwebbiz.com/kchandureddy/


thank u


from


Indian