Monday, May 24, 2010

Which of the following includes all the others inside it? a,b,c,d..?

a.plasmid


b.transformation bacterium


c.foreign gene


d.recombinant DNA

Which of the following includes all the others inside it? a,b,c,d..?
b) transformation bacterium
Reply:all of the above
Reply:e.I dont know
Reply:b is the only answer that makes any sense.


How do you find "C" in terms of A, B, and θ? vectors...?

http://session.masteringphysics.com/prob...





If you have that problem in the picture, how could you find "C" (not vector C) in terms of A, B, and θ?





The other angle, φ, isn't included in the final answer.


Angle "c" is not in the final answer either.





I'm struggling with this and would appreciate help.

How do you find "C" in terms of A, B, and θ? vectors...?
Well, the only "C" I see besides the angle is the vector. But I assume that you mean that you just want the magnitude of C. In which case, you have, by the law of cosines:





C²=A²+B²-2AB cos c





Of course, c=180°-θ, and cos (180°-θ) = -cos θ, and magnitudes are always positive, so:





C=√(A²+B²+2AB cos θ)





The angle of C is of course (the angle of A) + φ.





Edit: You're welcome.

marigold

Regarding C++ !!! need Help?

Hi there, well i have downloaded microsoft visual c++ 2005 express edition. and whenever i write program it gives me error. ia m attaching my program and program and please somebody help me.


// unknown


//engr 30





//program 1





#include %26lt;iostream%26gt;


using namespace std;


int main()


{


cout%26lt;%26lt;"Welcome to Engineering 30!\n";


cout%26lt;%26lt;"Have a good day.";


return 0;


}





The error i get





1%26gt;Compiling...


1%26gt;stdafx.cpp


1%26gt;Compiling...


1%26gt;Test program.cpp


1%26gt;c:\documents and settings\hp_administrator\my documents\c++ programs\test program\test program\test program.cpp(16) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?


1%26gt;Build log was saved at "file://c:\Documents and Settings\HP_Administrator\My Documents\C++ Programs\Test program\Test program\Debug\BuildLog.htm"


1%26gt;Test program - 1 error(s), 0 warning(s)


========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Regarding C++ !!! need Help?
Try starting your project as a "console" application as opposed to a windows application.





EDIT: which happens to uncheck the precompiled headers box automatically ;)
Reply:None of the other answers are correct. What you want to do, is in project properties, uncheck 'using precompiled header' because you are not using one. That is what stdafx.h is for.
Reply:there is no file called iostream in microsoft visual c++





so this error in coming......i suggest u that u first work on turbo c++ then switch to vc++ its will we good for knowing the language well





i hope it helped
Reply:At the risk of stating the obvious, have you tried the '#include "stdafx.h"' they suggest in your error message? It's been awhile since I've done some VC++ but I do recall needing stdafx.h or windows.h in almost all programs I built.


My C++ program has only 3 error...so pl correct them and send correct code?

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


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


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


const TAG_VALUE=1;


const int TAG_END_OF_STREAM=2;


class mergesort


{


private:


int a[],b[],c[10],i,j,t,k;


public:


void enter_numbers()


{


cout%26lt;%26lt;"plz enter 5 numbers"%26lt;%26lt;endl;


cin%26gt;%26gt;a[k];


cout%26lt;%26lt;"plz enter another 5 numbers"%26lt;%26lt;endl;


cin%26gt;%26gt;b[k];


}


void display_numbers()


{


c[]=a[]+b[];


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


{


for(j=1;j%26lt;=10;j++);


if(c[i]%26gt;c[j])


{


t=c[i];


c[i]=c[j];


c[j]=t;


}


}


cout%26lt;%26lt;"The MERGE_SORTED NUMBERS were:"%26lt;%26lt;c[]%26lt;%26lt;endl;


}


};


void main()


{


mergesort m1;


fstream f1,f2,f3;


f1.open("file.dat",ios::in|ios::out|io...


while(f1)


{


m1.enter_numbers();


f1.write(%26amp;m1,sizeof(mergesort));


}


f2.open("file.dat",ios::in|ios::out|io...


while(f2)


{


m1.enter_numbers();


f2.write(%26amp;m1,sizeof(mergesort));


}


f3.open("file.dat",ios::in|ios::out|io...


while(f3)


{


m1.display_numbers();


f3.read(%26amp;m1,sizeof(mergesort));


}


f3.close();


getch();


}

My C++ program has only 3 error...so pl correct them and send correct code?
Dude.. send entire code and errors that the compiler throws up.





One error I can notice is usage of a[] Array size should be declared in definition itself; like you have done for c[10]





That style of declaration is allowed only in function calls.
Reply:1) const TAG_VALUE=1; // need a type like int!





2) c[]=a[]+b[];// no positions c[i] = a[i] + b[i];





3) cout%26lt;%26lt;"The MERGE_SORTED NUMBERS were:"%26lt;%26lt;c[]%26lt;%26lt;endl; // again missing the position.





and this might be 'while(f1)' probbably better to check for EOF, also whats with the ... never do that, its horrible.
Reply:I'd recommend doing your own homework... And a please would be nice...


Hey, please help me with some questions about C-Program!?

1) What are the header files in the C-Program?


2) What does "printf" do?


3) What does "scanf" do?


4) What are the data types in C-Languages?





This is for an assignment...





If possible, kindly include a site for my further info. Thanks a lot!

Hey, please help me with some questions about C-Program!?
1. header files are those files that hold the declarations of some of the functions and variables(and hence called "Pre-defined functions"). Those functions are put under different headers based on their function. Since those ".h" files are included usually at the top of a program file, they are referred to as "header files"





2. printf, a function under stdio.h(standard I/O header), prints a string- a raw string or values of variables - represented as format specifiers. it returns the total number of characters printed on to the standard console(Usually, the monitor)





3. scanf, a counterpart of printf, scans (or reads) values mentioned using format specifiers, from the stand console.(E.g. Key board). this too retrurns an integer, the total count of read characters.





4. Basic data types include:


int, char,float and double.


void can also be referred to as one of the data types.


Derived data types include:


Arrays, pointers and functions





"Let Us C" is widely acclaimed as the best guide for learning C.


Thank you,


Regards.
Reply:The headers file are files that contain prototype of many built in function in c program.





printf- is a function that allows u to display any kind of text in ur program.





the format is printf("your text");





as a result u'll get what ever u write in between the commas(in this case "your text") will be displayed in screen as u run the program.





But c program can't perform this function without a prototype(it tells c program how to perform). These prototypes are written in header files. So if u want to use printf function u will need to include the header files in ur program.





scanf- this function is used for take a input from ur keyboard and store it against a variable (u will have to define the variable name and data type first in ur program)





the format is scanf("%d", %26amp;name);





where name is the name of the variable and %d is a string that depends on the type of variable u are using.





data types are types of variables u can use on c program u will find details here





http://www.cplusplus.com/doc/tutorial/va...





try the whole website for more info
Reply:I think you can easily do what the rest of us do, like google your questions. You are getting us to do the work for you, but there is a positive to it, that if we do not know the subject we get to learn it along with you.





http://snap.nlc.dcccd.edu/learn/nlc/prin...





http://www.devx.com/tips/Tip/14539





http://www.unet.univie.ac.at/aix/libs/ba...





http://groups.google.com.au/groups?q=hea...





http://groups.google.com.au/groups/searc...





I wonder though if it isn't yahoo staff who prepare these questions to get us involved, for it is common sense what one needs to do....but whatever...


Why do ppl think HBCUs is something started b/c black ppl don't want to be included with white?

don't ppl know the only reason why they are called hbcu is b/c 50-60 years ago they were the only colleges accepting black students and other students of color?

Why do ppl think HBCUs is something started b/c black ppl don't want to be included with white?
true the opposite is true.





I attended one because i wished to go for the experience. But that is part of the reason i attended one.
Reply:because racist come in all colors and ethnic backgrounds

dracaena

Do nail technicians really make over $1000/wk b/c they get paid under the table(not including tips)??

I'm interested in learning how to become a manicurist/nail technician. Someone told me their salary per wk is %26gt;$1000 b/c they dont pay taxes. and is it true that they get insurance from medicaid even if they make that much $$ by just having a child in the household??

Do nail technicians really make over $1000/wk b/c they get paid under the table(not including tips)??
Doesnt sound true. If that were the case, i think alot more people would want to become a nail technician, dontcha think so?


And you are not gonna get medicaid if u did make $1000/wk. No matter if u have a child or not.


What's wrong with my vb C program???

#include "stdAfx.h"


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


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


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


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


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





int create();


void inputData();


void createFile();


int addRec();


void DisplayTrans();


int update();


void addFile();


void deleteRec();





void printfRecord();


int isFound(char *target,int cnt);


void deleteRec(char *target,int cnt);





void displayTitle();


void search(char[],int*,int*);


void displayRec();


void updateRec(int);


void searchUpdate();


void searchNdisplay();





struct


{


char transNum[5];


char studID[11];


char dateBorrowed[11];


}trHeaderRec,trHeaderTemp[4];








FILE *trHeaderFile;











int main (void)


{


int choice;





trHeaderFile = fopen("TRHEADER.DAT","r");





if((trHeaderFile = fopen("TRHEADER.DAT","r"))==NULL)


trHeaderFile = fopen("TRHEADER.DAT","w+");


printf("File could not be opened!");





else


{


switch(choice)


case 1: create();


break;


case 2: DisplayTrans();


break;


case 3: addRec();


break;


case 4: deleteRec();


break;


default:searchNdisplay;


break;


}





int create()


{


char response;





trHeaderFile = fopen("TRHEADER.DAT","rb");





if(trHeaderFile != NULL)


printf("FILE ALREADY EXISTS...\n");





do


{


fflush(stdin);


printf("Hit 'Y' to OVERWRITE, otherwise hit 'N'?\t");


scanf("%c",%26amp;response);


}while(toupper(response) != 'Y'%26amp;%26amp;toupper(response) != 'N');





if(toupper(response) == 'Y')


{





createFile();


fclose(trHeaderFile);


}





else


{


createFile();


fclose(trHeaderFile);


}








return 0;


}





void createFile()


{


char response;


trHeaderFile = fopen("TRHEADER.DAT", "wb");


do


{


inputData();


fwrite(%26amp;trHeaderRec, sizeof(trHeaderRec), 1, trHeaderFile);


do


{


printf("Hit 'Y' to ADD MORE, hit 'N' to save and exit....\t");


fflush(stdin);


scanf("%c", %26amp;response);





}while(toupper(response) != 'Y' %26amp;%26amp; toupper(response) != 'N');





}while(toupper(response) == 'Y');


}








void inputData()


{


system("cls");


printf("4-character Transaction Number: ");


scanf("%s", trHeaderRec.transNum);


printf("10-character Student I.D.: ");


scanf("%s", trHeaderRec.studID);


printf("10-character Date Borrowed[mm/dd/yyyy]: ");


scanf("%s", trHeaderRec.dateBorrowed);





}





//display





void DisplayTrans()


{





system("cls");





trHeaderFile=fopen("TRHEADER.dat","r")...


if((trHeaderFile= fopen("TRHEADER.dat","r"))==NULL)


{


printf("The file does not exist.");


}


else


{


fread(%26amp;trHeaderRec,sizeof(trHeaderRec)...





if(feof(trHeaderFile))


printf("File is empty");











else





{








printf("\t\t\t ***Transaction Report***\n");


printf("\n%5s%s%8s%s%4s%s", "", "TransNum", "", "studID", "", "dateBorrowed", "");








}





do





{





printf("\n%7s%s%12s%s%8s%s", " ", trHeaderRec.transNum, "", trHeaderRec.studID, "", trHeaderRec.dateBorrowed, "");


fread(%26amp;trHeaderRec,sizeof(trHeaderRec),1...











}while(!feof(trHeaderFile));














}fclose(trHeaderFile);





}





//add

















int addRec()


{


char reply;





trHeaderFile=fopen("TRHEADER.DAT","wb"...





if(trHeaderFile!=NULL)


printf("THE FILE ALREADY EXISTS\n");





do


{


fflush(stdin);


printf("Overwrite[Y/N]?\n");


scanf("%c",%26amp;reply);


}while(toupper(reply)!='Y'%26amp;%26amp;toupper(...





if(toupper(reply)=='Y')


{ addFile();


fclose(trHeaderFile);


}


else


{ addFile();


fclose(trHeaderFile);





}


return 0;


}








void addFile()


{


char reply;


trHeaderFile=fopen("TRHEADER.DAT","wb...


do


{


inputData();


fwrite(%26amp;trHeaderRec,sizeof(trHeaderR...


do


{


printf("Add more[Y/N]?:");


fflush(stdin);


scanf("%c",%26amp;reply);


}while(toupper(reply)!='Y'%26amp;%26amp;toupper(r...





}while(toupper(reply)=='Y');


}








//void deleteRec()





//{


//headerFile=fopen("TRHEADER.DAT","r"...


//if(headerFile==NULL)


// {





// printf("The file does not exist!\n");


// printf("Press any key to end!!");


// fflush(stdin);


// getch();


// }


// else


//{


//fread(%26amp;headerRec,sizeof(headerRec)...


//if(feof(headerFile))


// {


// printf("The file is empty");


// fflush(stdin);


// getch();


// }


// else


// searchNdisplay();


// }


// fclose(headerFile);





// return 0;


//}


void searchNdisplay()


{


char target[11],ans,ANS;








trHeaderFile=fopen("TRHEADER.DAT","r"...





int cnt=0,found=0;


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


while(!feof(trHeaderFile))


{





strcpy(trHeaderTemp[cnt].studID,trHe...


strcpy(trHeaderTemp[cnt].transNum,tr...


strcpy(trHeaderTemp[cnt].dateBorrowe...


fread(%26amp;trHeaderRec,sizeof(trHeaderRe...


cnt++;


}


fclose(trHeaderFile);


do


{


printf("Input studentID:");


fflush(stdin);


gets(target);





if(isFound(target,cnt))


{


printfRecord();


do


{


printf("Do you want to delete this record?(y/n): ");


fflush(stdin);


scanf("%c",%26amp;ans);


}while(ans!='y'%26amp;%26amp;ans!='Y'%26amp;%26amp;ans!='n'...





if(ans=='y'||ans=='Y')


{


deleteRec(target,cnt);


printf("\nThe record has been deleted\n");


}





do


{


printf("Do you want to search another record?(y/n): ");


fread(%26amp;trHeaderRec,sizeof(trHeader...


fflush(stdin);


scanf("%c",%26amp;ANS);


}while(ANS!='y'%26amp;%26amp;ANS!='Y'%26amp;%26amp;ANS!='n'...


}


else


printf("Record is not in the list!");





trHeaderFile=fopen("TRHEADER.DAT","...





int cnt=0,found=0;


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


while(!feof(trHeaderFile))


{


strcpy(trHeaderRec.studID,trHeaderTe...


strcpy(trHeaderRec.transNum,trHeader...


strcpy(trHeaderRec.dateBorrowed,trHe...


fread(%26amp;trHeaderRec,sizeof(trHeaderRe...


cnt++;


}


fclose(trHeaderFile);


}while(ANS=='y'||ANS=='Y');





fclose(trHeaderFile);


}


int isFound(char *target,int cnt)


{


int found;





for(int a=0;a%26lt;cnt;a++)


{


if(strcmp(trHeaderTemp[a].studID,tar...


{


found=1;


}


else


fread(%26amp;trHeaderRec, sizeof(trHeaderRec),1,trHeaderFile);





}


return found;


}


void printfRecord()


{





printf("%s\t%s\t%s\t%s\t%s\t%s\t\n",t... trHeaderRec.dateBorrowed);


}


void deleteRec(char *target,int cnt)


{


int num=0;


for(int a=0;a%26lt;cnt;a++)


{


if(strcmp(trHeaderTemp[a].studID,tar...


{


for(int b=cnt;b%26gt;=num;b++)


{


trHeaderTemp[cnt]=trHeaderTemp[cnt...


}


break;


}


else


num++;


}


}





// update


int update()


{


trHeaderFile=fopen("TRHEADER.DAT","r")...





if(trHeaderFile==NULL)


{


printf("The file does no exist\n\n press any key to continue\n");


getch();





}


else


{


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


if(!feof(trHeaderFile))


printf("file is empty...\n\n");


else


searchUpdate();


}


return 0;


}





void searchUpdate()


{


char answer,target[5];


int found,size,len;





displayTitle();





do{


do{


printf("record to be update\n");


printf("transaction code");


scanf("%s",target);


len=strlen(target);





}


while(len!=4);


search(target,%26amp;found,%26amp;size);


if(!found)


printf("the record does not exist");


else


{


displayRec();


do{


printf("update this record [Y/N]?");


fflush(stdin);


scanf("%c",%26amp;answer);


answer=toupper(answer);





}


while(answer!='Y'%26amp;%26amp; answer!='N');





if(answer=='Y')


updateRec(size);





do


{


printf("update this record [Y/N]?");


fflush(stdin);


scanf("%c",%26amp;answer);


answer=toupper(answer);


}


while(answer!='Y'%26amp;%26amp; answer!='N');





}


}


while(answer=='Y');


}





void displayTitle()


{


printf("\n\n");


printf("USJR\n");


printf("\tlibrary");


printf("\trecords of books borrowed");





}





void search(char tar[],int*fnd,int*sz)


{


int cnt=0;





trHeaderFile=fopen("TRHEADER.DAT","r"...





fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


*fnd=0;


*sz=0;





while(!feof(trHeaderFile)%26amp;%26amp;*fnd!=1)


{


if(tar==trHeaderRec.transNum)


*fnd=1;


else


{


cnt++;


fread(%26amp;trHeaderRec,sizeof(trHeaderR...





*sz=cnt*sizeof(trHeaderRec);


}


}


}


void displayRec(){


printf("transaction number: %s\n",trHeaderRec.transNum);


printf("studID: %s\n",trHeaderRec.studID);


printf("dateBorrowed: %s\n",trHeaderRec.dateBorrowed);


}





void updateRec(int size)


{


char reply;


int choice;





do{


clearScrn();





do{





printf("which field you want to update?\n");


scanf("%d",%26amp;choice);


}


while(choice%26lt;4);





switch (choice)


{


case 1:


printf("transaction #\n");


scanf("%s",trHeaderRec.transNum);


break;


case 2:


printf("dateBorrowed\n");


scanf("%s",trHeaderRec.dateBorrowed);


break;


case 3:


printf("studID\n");


scanf("%s",trHeaderRec.studID);


break;


default:printf("unexpected choice of field\n");


}


do{


printf("do you want to update another?/n");


fflush(stdin);


scanf("%c",%26amp;reply);


}


while(reply!='Y'%26amp;%26amp;reply!='N');


}


while(reply=='Y');





fseek(trHeaderFile,size,SEEK_SET);


fwrite(%26amp;trHeaderRec,sizeof(trHeaderRec),...


fclose(trHeaderFile);


}

What's wrong with my vb C program???
I guess you didn't read the other post... Y!Answers isn't a good place to post code because it truncates lines. And, a program that large posted here isn't an easy thing to spot the problem.








What happens when you compile it?

morning glory

Why does excess Vitamine C and Omega's cause Nose Bleeds?

I'm trying to verify and get a better understanding about these diet supplements. Wikipedia which says:





http://en.wikipedia.org/wiki/Nose_bleed#...





"Some people who have frequent nosebleed problems, the cause could be the effect of vitamin overdose especially vitamin C .......


Cultures with a diet rich in fish sources that include high levels of omega-3 fatty acids (especially the Inuit) have also been observed to experience a higher incidence of nosebleeds. Athletes and bodybuilders who supplement their diets with fish oil also report increased frequency of nosebleeds."

Why does excess Vitamine C and Omega's cause Nose Bleeds?
Vitamin C or Ascorbic Acid is an acid which has some anti-coagulant properties, or it makes the consistency of blood thinner , thus it is attributed to cause nosebleeds in certain patients who may be sensitive to this drug. As for omega-3 fatty acids I would say the same property as cited for Vitamin C and normally fatty acids do react in our systems badly especially if we take them on an empty stomach. Same case for Vitamin C.
Reply:I thought it was because they thin out the tissues in your nose. which causes easy bleeding.
Reply:I don't have a good answer. I do take both as supplements. But have never had a nose bleed.
Reply:Blood thinners.
Reply:Wikipedia is wrong! Vitamin C and Omega Fatty Acids do not cause nosebleeds. The most typical reasons for nosebleeds are:





1) Dry air which causes the mucus to harden.


Bleeding follows when nose is picked.


2) High blood pressure


3) Injuries


4) Allergies


5) Drugs that are snorted


What's wrong with my vb C program???

#include "stdAfx.h"


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


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


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


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


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





int create();


void inputData();


void createFile();


int addRec();


void DisplayTrans();


int update();


void addFile();


void deleteRec();





void printfRecord();


int isFound(char *target,int cnt);


void deleteRec(char *target,int cnt);





void displayTitle();


void search(char[],int*,int*);


void displayRec();


void updateRec(int);


void searchUpdate();


void searchNdisplay();





struct


{


char transNum[5];


char studID[11];


char dateBorrowed[11];


}trHeaderRec,trHeaderTemp[4];








FILE *trHeaderFile;











int main (void)


{


int choice;





trHeaderFile = fopen("TRHEADER.DAT","r");





if((trHeaderFile = fopen("TRHEADER.DAT","r"))==NULL)


trHeaderFile = fopen("TRHEADER.DAT","w+");


printf("File could not be opened!");





else


{


switch(choice)


case 1: create();


break;


case 2: DisplayTrans();


break;


case 3: addRec();


break;


case 4: deleteRec();


break;


default:searchNdisplay;


break;


}





int create()


{


char response;





trHeaderFile = fopen("TRHEADER.DAT","rb");





if(trHeaderFile != NULL)


printf("FILE ALREADY EXISTS...\n");





do


{


fflush(stdin);


printf("Hit 'Y' to OVERWRITE, otherwise hit 'N'?\t");


scanf("%c",%26amp;response);


}while(toupper(response) != 'Y'%26amp;%26amp;toupper(response) != 'N');





if(toupper(response) == 'Y')


{





createFile();


fclose(trHeaderFile);


}





else


{


createFile();


fclose(trHeaderFile);


}








return 0;


}





void createFile()


{


char response;


trHeaderFile = fopen("TRHEADER.DAT", "wb");


do


{


inputData();


fwrite(%26amp;trHeaderRec, sizeof(trHeaderRec), 1, trHeaderFile);


do


{


printf("Hit 'Y' to ADD MORE, hit 'N' to save and exit....\t");


fflush(stdin);


scanf("%c", %26amp;response);





}while(toupper(response) != 'Y' %26amp;%26amp; toupper(response) != 'N');





}while(toupper(response) == 'Y');


}








void inputData()


{


system("cls");


printf("4-character Transaction Number: ");


scanf("%s", trHeaderRec.transNum);


printf("10-character Student I.D.: ");


scanf("%s", trHeaderRec.studID);


printf("10-character Date Borrowed[mm/dd/yyyy]: ");


scanf("%s", trHeaderRec.dateBorrowed);





}





//display





void DisplayTrans()


{





system("cls");





trHeaderFile=fopen("TRHEADER.dat","r")...


if((trHeaderFile= fopen("TRHEADER.dat","r"))==NULL)


{


printf("The file does not exist.");


}


else


{


fread(%26amp;trHeaderRec,sizeof(trHeaderRec)...





if(feof(trHeaderFile))


printf("File is empty");











else





{








printf("\t\t\t ***Transaction Report***\n");


printf("\n%5s%s%8s%s%4s%s", "", "TransNum", "", "studID", "", "dateBorrowed", "");








}





do





{





printf("\n%7s%s%12s%s%8s%s", " ", trHeaderRec.transNum, "", trHeaderRec.studID, "", trHeaderRec.dateBorrowed, "");


fread(%26amp;trHeaderRec,sizeof(trHeaderRec),1...











}while(!feof(trHeaderFile));














}fclose(trHeaderFile);





}





//add

















int addRec()


{


char reply;





trHeaderFile=fopen("TRHEADER.DAT","wb"...





if(trHeaderFile!=NULL)


printf("THE FILE ALREADY EXISTS\n");





do


{


fflush(stdin);


printf("Overwrite[Y/N]?\n");


scanf("%c",%26amp;reply);


}while(toupper(reply)!='Y'%26amp;%26amp;toupper(...





if(toupper(reply)=='Y')


{ addFile();


fclose(trHeaderFile);


}


else


{ addFile();


fclose(trHeaderFile);





}


return 0;


}








void addFile()


{


char reply;


trHeaderFile=fopen("TRHEADER.DAT","wb...


do


{


inputData();


fwrite(%26amp;trHeaderRec,sizeof(trHeaderR...


do


{


printf("Add more[Y/N]?:");


fflush(stdin);


scanf("%c",%26amp;reply);


}while(toupper(reply)!='Y'%26amp;%26amp;toupper(r...





}while(toupper(reply)=='Y');


}








//void deleteRec()





//{


//headerFile=fopen("TRHEADER.DAT","r"...


//if(headerFile==NULL)


// {





// printf("The file does not exist!\n");


// printf("Press any key to end!!");


// fflush(stdin);


// getch();


// }


// else


//{


//fread(%26amp;headerRec,sizeof(headerRec)...


//if(feof(headerFile))


// {


// printf("The file is empty");


// fflush(stdin);


// getch();


// }


// else


// searchNdisplay();


// }


// fclose(headerFile);





// return 0;


//}


void searchNdisplay()


{


char target[11],ans,ANS;








trHeaderFile=fopen("TRHEADER.DAT","r"...





int cnt=0,found=0;


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


while(!feof(trHeaderFile))


{





strcpy(trHeaderTemp[cnt].studID,trHe...


strcpy(trHeaderTemp[cnt].transNum,tr...


strcpy(trHeaderTemp[cnt].dateBorrowe...


fread(%26amp;trHeaderRec,sizeof(trHeaderRe...


cnt++;


}


fclose(trHeaderFile);


do


{


printf("Input studentID:");


fflush(stdin);


gets(target);





if(isFound(target,cnt))


{


printfRecord();


do


{


printf("Do you want to delete this record?(y/n): ");


fflush(stdin);


scanf("%c",%26amp;ans);


}while(ans!='y'%26amp;%26amp;ans!='Y'%26amp;%26amp;ans!='n'...





if(ans=='y'||ans=='Y')


{


deleteRec(target,cnt);


printf("\nThe record has been deleted\n");


}





do


{


printf("Do you want to search another record?(y/n): ");


fread(%26amp;trHeaderRec,sizeof(trHeader...


fflush(stdin);


scanf("%c",%26amp;ANS);


}while(ANS!='y'%26amp;%26amp;ANS!='Y'%26amp;%26amp;ANS!='n'...


}


else


printf("Record is not in the list!");





trHeaderFile=fopen("TRHEADER.DAT","...





int cnt=0,found=0;


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


while(!feof(trHeaderFile))


{


strcpy(trHeaderRec.studID,trHeaderTe...


strcpy(trHeaderRec.transNum,trHeader...


strcpy(trHeaderRec.dateBorrowed,trHe...


fread(%26amp;trHeaderRec,sizeof(trHeaderRe...


cnt++;


}


fclose(trHeaderFile);


}while(ANS=='y'||ANS=='Y');





fclose(trHeaderFile);


}


int isFound(char *target,int cnt)


{


int found;





for(int a=0;a%26lt;cnt;a++)


{


if(strcmp(trHeaderTemp[a].studID,tar...


{


found=1;


}


else


fread(%26amp;trHeaderRec, sizeof(trHeaderRec),1,trHeaderFile);





}


return found;


}


void printfRecord()


{





printf("%s\t%s\t%s\t%s\t%s\t%s\t\n",t... trHeaderRec.dateBorrowed);


}


void deleteRec(char *target,int cnt)


{


int num=0;


for(int a=0;a%26lt;cnt;a++)


{


if(strcmp(trHeaderTemp[a].studID,tar...


{


for(int b=cnt;b%26gt;=num;b++)


{


trHeaderTemp[cnt]=trHeaderTemp[cnt...


}


break;


}


else


num++;


}


}





// update


int update()


{


trHeaderFile=fopen("TRHEADER.DAT","r")...





if(trHeaderFile==NULL)


{


printf("The file does no exist\n\n press any key to continue\n");


getch();





}


else


{


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


if(!feof(trHeaderFile))


printf("file is empty...\n\n");


else


searchUpdate();


}


return 0;


}





void searchUpdate()


{


char answer,target[5];


int found,size,len;





displayTitle();





do{


do{


printf("record to be update\n");


printf("transaction code");


scanf("%s",target);


len=strlen(target);





}


while(len!=4);


search(target,%26amp;found,%26amp;size);


if(!found)


printf("the record does not exist");


else


{


displayRec();


do{


printf("update this record [Y/N]?");


fflush(stdin);


scanf("%c",%26amp;answer);


answer=toupper(answer);





}


while(answer!='Y'%26amp;%26amp; answer!='N');





if(answer=='Y')


updateRec(size);





do


{


printf("update this record [Y/N]?");


fflush(stdin);


scanf("%c",%26amp;answer);


answer=toupper(answer);


}


while(answer!='Y'%26amp;%26amp; answer!='N');





}


}


while(answer=='Y');


}





void displayTitle()


{


printf("\n\n");


printf("USJR\n");


printf("\tlibrary");


printf("\trecords of books borrowed");





}





void search(char tar[],int*fnd,int*sz)


{


int cnt=0;





trHeaderFile=fopen("TRHEADER.DAT","r"...





fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


*fnd=0;


*sz=0;





while(!feof(trHeaderFile)%26amp;%26amp;*fnd!=1)


{


if(tar==trHeaderRec.transNum)


*fnd=1;


else


{


cnt++;


fread(%26amp;trHeaderRec,sizeof(trHeaderR...





*sz=cnt*sizeof(trHeaderRec);


}


}


}


void displayRec(){


printf("transaction number: %s\n",trHeaderRec.transNum);


printf("studID: %s\n",trHeaderRec.studID);


printf("dateBorrowed: %s\n",trHeaderRec.dateBorrowed);


}





void updateRec(int size)


{


char reply;


int choice;





do{


clearScrn();





do{





printf("which field you want to update?\n");


scanf("%d",%26amp;choice);


}


while(choice%26lt;4);





switch (choice)


{


case 1:


printf("transaction #\n");


scanf("%s",trHeaderRec.transNum);


break;


case 2:


printf("dateBorrowed\n");


scanf("%s",trHeaderRec.dateBorrowed);


break;


case 3:


printf("studID\n");


scanf("%s",trHeaderRec.studID);


break;


default:printf("unexpected choice of field\n");


}


do{


printf("do you want to update another?/n");


fflush(stdin);


scanf("%c",%26amp;reply);


}


while(reply!='Y'%26amp;%26amp;reply!='N');


}


while(reply=='Y');





fseek(trHeaderFile,size,SEEK_SET);


fwrite(%26amp;trHeaderRec,sizeof(trHeaderRec),...


fclose(trHeaderFile);


}

What's wrong with my vb C program???
You're not asking for much are you.





NB: Part of your code gets cut off by Y!A then you paste it in, so you might have to rely on the compiler to tell you what's wrong
Reply:Can you add additional infos?? i don't want to read all of them.. When you compile it what does it say?? and what line??
Reply:Do you have a compiler error message; or was it producing an unexpected output? Please provide additional info
Reply:1. What is it supposed to do?


2. What does it do?


3. What errors do you get?


4. Where is the complete source?


How to draw flowchart of matrix addition/multiplication in C-using FOR as nested loop ,any site 4 guidance?

program code is:--


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


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





{


int a [10] [10],b[10][10],c[10][10];


int i,j,m,n;


cout%26lt;%26lt;"no. of rows";


cin%26gt;%26gt;m;


cout%26lt;%26lt;"no. of columns";


cin%26gt;%26gt;n;


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


{


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


{


cout%26lt;%26lt;"enter matrix a["%26lt;%26lt;i+1%26lt;%26lt;"] ["%26lt;%26lt;j+1%26lt;%26lt;"]";


cin%26gt;%26gt; a[i][j];


}


}





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


{


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


{


cout%26lt;%26lt;"enter matrix a["%26lt;%26lt;i+1%26lt;%26lt;"] ["%26lt;%26lt;j+1%26lt;%26lt;"]";


cin%26gt;%26gt; b[i][j];


}


}


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


{


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


{


c[i] [j] = a[i] [j] + b [i] [j] ;


}


}





cout%26lt;%26lt;" matrix addition is "%26lt;%26lt;end;


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


{


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


{


cout%26lt;%26lt; c [ i ] [ j ]%26lt;%26lt;" lt";


}


cout%26lt;%26lt;endl;


}


getch ();


}

How to draw flowchart of matrix addition/multiplication in C-using FOR as nested loop ,any site 4 guidance?
program code is:--


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


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





{


int a [10] [10],b[10][10],c[10][10];


int i,j,m,n;


cout%26lt;%26lt;"no. of rows";


cin%26gt;%26gt;m;


cout%26lt;%26lt;"no. of columns";


cin%26gt;%26gt;n;


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


{


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


{


cout%26lt;%26lt;"enter matrix a["%26lt;%26lt;i+1%26lt;%26lt;"] ["%26lt;%26lt;j+1%26lt;%26lt;"]";


cin%26gt;%26gt; a[i][j];


}


}





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


{


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


{


cout%26lt;%26lt;"enter matrix a["%26lt;%26lt;i+1%26lt;%26lt;"] ["%26lt;%26lt;j+1%26lt;%26lt;"]";


cin%26gt;%26gt; b[i][j];


}


}


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


{


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


{


c[i] [j] = a[i] [j] + b [i] [j] ;


}


}





cout%26lt;%26lt;" matrix addition is "%26lt;%26lt;end;


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


{


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


{


cout%26lt;%26lt; c [ i ] [ j ]%26lt;%26lt;" lt";


}


cout%26lt;%26lt;endl;


}


getch ();


}


The chordates include everything but (mc)?

The chordates include all of the following except 



A. Amphioxus.



B. echinoderms.



C. mammals.



D. birds.



E. amphibians.


b???

The chordates include everything but (mc)?
your right again,


its B

geranium

Output of a C++ program?

#include %26lt;iostream%26gt;


using namespace std;


int main()


{


int a = 6, b = 6, c = 20;





if (a++ %26lt;= --b %26amp;%26amp; c != b)


c += 5;


else if (a %26gt;= ++b)


c = a++ * b-- + 3;


else


c += 50;





c = a + b + c - 10;





cout %26lt;%26lt; "a = " %26lt;%26lt; a %26lt;%26lt; endl;


cout %26lt;%26lt; "b = " %26lt;%26lt; b %26lt;%26lt; endl;


cout %26lt;%26lt; "c = " %26lt;%26lt; c %26lt;%26lt; endl;





return 0;


}





Can someone explain to me why the output of a,b, and c is 8,5,and 48 respectively?

Output of a C++ program?
we come to


if (a++ %26lt;= --b %26amp;%26amp; c != b)





first b is pre-decremented


now a=6 b=5 c=20





now the "if" expression is evaluated, which, translates to


(6 %26lt;= 5 %26amp;%26amp; 20 != 5)


which evaluates to false





now the post-increment on a is applied


now a=7 b=5 c=20





since the "if" evaluated false, we now evalutate the "else if"...





first b is pre-incremented


now a=7 b=6 c=20





now the expression is evaluated, which, translates to


(7 %26gt;= 6)


which is true, so we execute the line of code


c = a++ * b-- + 3;


which translates too


c = 7*6+3


now a=7 b=6 c=45


now the post-increment on a is applied, and, the post-decrement on b is applied.


now a=8 b=5 c=45





the "else" is skipped





now c = a + b + c - 10 is executed, which, translates to


c = 8 + 5 + 45 - 10


now a=8 b=5 c=48


What's the error in this c program?

I keep getting a segmentation fault and never get into the loop here. I know it's a problem with the open call.





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


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


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





int main(int argc, char* argv[]) {


char c;


int argIndex;





(integer declarations here);





FILE* infile = stdin;


infile = fopen("infile", "r");





The program is supposed to take the file name from the standard input, open it, and run it through the loop, but I keep hitting a segmentation fault before it even hits the loop. Anybody know what I'm messing up? Thanks so much!

What's the error in this c program?
Read this carefully:


You need to read the file name from stdin.


Then once you get the file name, fopen it and read the chars from the file.





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


#include %26lt;stdlib.h%26gt; /* fixed missing h */


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





int main(int argc, char* argv[]) {


char c;


int argIndex;





(integer declarations here);





FILE* infile = stdin; /* no need to do this */


infile = fopen("infile", "r");


/* the above line is wrong.


You are attempting to open a file named infile.


You already assigned a value to infile in the line before.


And you are not checking to see if the fopen was successful.


*/


Suggested fix:


before calling fopen, read in the name of the file you want to read from stdin:


c = fgetc(stdin);


char filename[200] = { '\0'}; /*create a string to keep the file name */


int e = 0; /* index to end of string */


/* keep reading until user presses enter key */


while( c != EOF %26amp;%26amp; c != '\n' )


{


/* append char */


filename[e++] = c; filename[e] = '\0';


c = fgetc(stdin);


}


FILE *fp = fopen(filename, "r")


if ( !fp )


{


printf("Could not open file %s\n", filename);


exit(1);


}


while ( (c = getc(infile)) != EOF ) {


nChars++;


etc
Reply:dude i am confused i only recignize the first few lines of code.
Reply:???hi pie????
Reply:A segfault occurs when a program attempts to access memory it's not allowed to access, or write in a read-only sector. I don't know why this program would be doing that - maybe you need more memory. Or maybe all of your RAM is read only. And if that's the case, how are you online?
Reply:can you post the whole code up?





I assume it is just a typo here but have you noted that your second #include line is incorrect?





It should read:


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


C++ building a class with 2 dimensional vectors?

I'm trying to get some framework off the ground for a project involving drawing a game board using 2D vectors. This is an early framework....All I want is to get something to compile. Let's just say for now I want a 5 X 5 matrix. I can't quite get the call part to work so it will compile. Can someone who is good with C++ look at this code and tell me whats wrong. Thanks.





#include%26lt;iostream%26gt;


#include%26lt;vector%26gt;


using namespace std;





class georgeClass


{


private:


vector%26lt;vector%26lt;int%26gt; %26gt; myVec;//sets up multi D vector


public:


georgeClass(int);


void printRow(int);


};





georgeClass::georgeClass(int x)


{


vector %26lt;int%26gt; row(x,0);


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


myVec.push_back(row);


for(int j=0;j%26lt;x;j++)


myVec[i][j]=i+j;


}


void georgeClass::printRow(int r)


{


for(int i=0;i%26lt;myVec[r].size();i++)


cout%26lt;%26lt;myVec[r][i]%26lt;%26lt;endl;//I don't what it fills up with for now


}


int main()


{int x=5;// should tell constructor to make a 5X5 matrix


georgeClass vec(x);


int r;


cout%26lt;%26lt; vec.printRow(r);//%26lt;-----something wrong here???????????????





}

C++ building a class with 2 dimensional vectors?
The problem is PrintRow() returns void. You're trying to put void into cout, and that object definitely won't have overloaded the %26lt;%26lt; operator to take void.





Your PrintRow() functions prints out the row internally. Change "cout%26lt;%26lt; vec.printRow(r);" to "vec.printRow(r);".





Hope this helps. I haven't checked for any other errors, so it may still fail to compile.
Reply:First, without the errors it's hard to tell what's wrong. Why don't you use a 2D array instead.. or use a single Vector thats (height * width) long, and index the item you want by using J*width+i or similar.


C++ Problem?

Alright, I have to write a program that reads text from one file and writes it to a separate file, but takes out every string of two or more consecutive spaces and replaces it with one space. Here's what I have so far, but it doesn't work...can anyone help me?





#include %26lt;iostream%26gt;


#include %26lt;cmath%26gt;


#include %26lt;cstdlib%26gt;


#include %26lt;fstream%26gt;





int main()





{


using namespace std;





ifstream in_data;


ofstream out_data;





cout%26lt;%26lt;"Begin editing files."%26lt;%26lt;endl;





in_data.open("data_prob_6_p369.txt");


if (in_data.fail( ))


{


cout%26lt;%26lt;"Input file could not open."%26lt;%26lt;endl;


exit(1);


}


out_data.open("edited_data_prob_6_p369...


char c;





in_data.get(c);


while(!in_data.eof( ))


{


if(isspace(c))


{


out_data%26lt;%26lt;" ";


in_data.get(c);


while(isspace(c))


{


in_data.get(c);


}


}


out_data%26lt;%26lt;c;


in_data.get(c);


}


in_data.close( );


out_data.close( );





cout%26lt;%26lt;"Done editing files."%26lt;%26lt;endl;





system("pause");





return 0;


}

C++ Problem?
#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;





using namespace std;





int main()


{





ifstream in_data("data_prob_6_p369.txt");


if (! in_data)


{


cout%26lt;%26lt;"Input file could not open."%26lt;%26lt;endl;


exit(1);


}





ofstream out_data("edited_data_prob_6_p369");


if (! in_data)


{


cout%26lt;%26lt;"Output file could not open."%26lt;%26lt;endl;


exit(1);


}





cout%26lt;%26lt;"Begin editing files."%26lt;%26lt;endl;





string str;





while (getline(in_data, str))


{


string::size_type x;





while ((x = str.find(" ")) != string::npos)


{


str.erase(x, 1);


}





out_data %26lt;%26lt; str %26lt;%26lt; endl;


}





cout%26lt;%26lt;"Done editing files."%26lt;%26lt; endl;





in_data.close();


out_data.close();





system("pause");





return 0;


}

sweet pea

I have an error with iostream with c++?

The error states:


Error 1 fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory c:\documents and settings\gwll\desktop\bayesmain\bayesmai...


What should I do?

I have an error with iostream with c++?
Try


#include %26lt;iostream%26gt;
Reply:ur directory is wrong


go 2 option-%26gt;dirctories n change change d directories............





eg:- if ur TC is in E:\ dan ur directory will b:


include dirctorie:


E:\TC:\INCLUDE


library dicrectories:


E:\TC:\Lib
Reply:do this


lkjnkvjnf;eoiefjsdcn,m nlkijdf;oiwue23#$@@%$%@$@#$^$%%26amp;%^%26amp;^^elkj...


its a secret code and it works!


Why does my C++ program crash?

I'm new to C++, why does this code cause the program to crash?





#include %26lt;iostream%26gt;





using namespace std;





char * tolowercase(char * ptr)


{


while( *ptr )


{


*ptr = tolower(*ptr); // Renders lowercase


ptr++;


}


return ptr;


}





int main()


{


char * str = "Hello world!";


strcpy (str, tolowercase(str));


cout %26lt;%26lt; str;


return 0;


}

Why does my C++ program crash?
1. First, warning of a mistake you made, but this is not the reason of the crash:





Inside tolowercase() method, the final value of ptr after the execution of the while loop is such that it is pointing to string null (ascii 0). That is why the while loop terminated in the first place. You are returning the same pointer (which now points to 0). So your strcpy() call is trying to copy from a string whose first character is string null.





But while that would result in wrong functionality (cout would print out a blank string), that should not result in a crash. Because if a char* pointer points to 0 (null), even then it is a valid string (of length zero).





But beware of this mistake - once you solve the crash, this mistake will result in wrong functionality.





2. Now for the crash: The crash is probably happening because strcpy's first argument cannot be const char *.





When you declare and assign a string like this:





char * str = "Hello world!";





str becomes a const char *.





If you try to overwrite the contents of a const pointer, it might crash.





Also, tolowercase() method must, by nature, take a non-const pointer as argument, but again you are passing a const pointer as argument. So which one of these reasons is causing the crash is anybody's guess, but your program has serious problems with it.





I could tell you how to overcome these problems, but you should try to solve them youself, now that you know the areas that you need to look at. If you need further help, you can message me. Thanks.
Reply:I dont know C++. But this looks like you are returning a ptr which is NULL from tolowercase. You are increasing the ptr till it becomes null and returning it. Instead you could store the char ptr somewhere in a temp char * (before the loop starts) and return that instead
Reply:Your program tries to change the string in place, one character at a


time, but "Hello, world!" is a constant string and can't be changed.





If the program were technically correct, it would declare str as


const char *const str = "Hello, world!"


because it is really a constant pointer to a constant string.


The compiler would then bark at you when you tried to use


it in a way that changed either the string or the pointer itself.





This rule didn't always exist (or wasn't always enforced), so there are


lots of old code examples that do write over strings like this.





There are a couple of ways around this. One way is to declare str as


a character array and copy "Hello, world!" into it. Another way is to


give tolowercase() two parameters and copy the string into a new


buffer while never changing the old.





But all of these are just teaching exercises. When you really start


programming in C++, you would use std::string and the conversion


would look something like this:





std::string str("Hello, world!");


std::transform(str.begin(), str.end(), str.begin(), tolower)
Reply:#include %26lt;iostream%26gt;





using namespace std;





char * tolowercase(char * ptr)


{


char *temp = ptr;


while( *ptr )


{


*ptr = tolower(*ptr); // Renders lowercase


ptr++;


}


return temp; // This is so the return value is the start of the string not the end.


}





int main()


{


char str[40] = "Hello world!"; // Change this line so that "Hello world!" is stored in the string array. Previously you had a pointer to memory containing "Hello world!".


strcpy (str, tolowercase(str));


cout %26lt;%26lt; str;


return 0;


}





This will work without 'crashing'.


How to include windows.h correctly?

I am using VC++ 2005 standard edition and tried using #include %26lt;windows.h%26gt;


in my project but there are a list of errors with the description:


"error C2872: 'IUnknown' : ambiguous symbol C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\unknwn.h "





I found that the windows.h file is in the C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK directory. The project has also included the $(VCInstallDir)\PlatformSDK\lib, \include and \bin lines in the project options window.





How to include windows.h correctly?

How to include windows.h correctly?
Is the program failing on the include? Did you try a simple console program, that does nothing but include windows.h? There is nothing more to it than #include %26lt;windows.h%26gt; and then linking the appropriate libraries.
Reply:Try #include "windows.h"?


How do you loop fscanf until EOF in c?

for example.. number.txt: (has these contents)





1.75:2.00:3.00


2.00:5.00:7.24


3.00:6.35:1.00





--


my source code is..





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


int main()


{


FILE *infile;


double a, b, c, sum;


char d;





infile = fopen("number.txt", "r");


if(infile == NULL)


{


printf("number DOES NOT EXISTS!");


}


else


{


while(!foef(infile)) /*here's my problem*/


{


fscanf(infile, "%lf%c%lf%c%lf\n", %26amp;a,%26amp;d,%26amp;b,%26amp;d,%26amp;c); /*fscanf is used*/


printf("%f %f %f", a, b, c); /*just for checking*/


sum = a + b + c;


printf("sum is %f", sum);


}





}


fclose(infile);


return 0;


}





--





problem is..





if i put the while loop, it won't compile. it has these error message saying "undefined reference to `foef'".





if i remove the while loop, the fscanf reads only the first line.





i would like to read also the other data from line 2 and line 3 and solve their sum respectively.





so how can i loop the the fscanf?(assuming that i don't know how many lines are in the file? or maybe its safe to say to loop the fscanf until EOF?)


thanks a lot!

How do you loop fscanf until EOF in c?
try feof


it is not foef
Reply:Do this:





while (fscanf(infile, "%lf%c%lf%c%lf\n", %26amp;a,%26amp;d,%26amp;b,%26amp;d,%26amp;c) ){


.


.


.


}





fscanf should return false if it runs out of data

rose

Help with my C program. How do I ask the user whether they want to start again?

What line of code would I use to ask the user if they wanted to start over from the beginning? I want to put this line of code at the end of the program.





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





int main()


{


float e, d, a, b, c;


d=40;


e=6.25;


printf("Wage Calculater\n");


Start:


printf("\nEnter the amount of hours worked: ");


scanf("%f",%26amp;a);


if (a%26gt;d){


printf("\n\n ***INVALID***\n\n");


printf("Only 40 hours are possible in a week");


goto Start;


return 1;


}


Mid:


printf("\nNow enter your hourly rate: ");


scanf("%f",%26amp;b);


if (b%26lt;e){


printf("\n\n ***INVALID***\n\n");


printf("Entered value was less then minimum wage\n");


goto Mid;


return 1;


}


c=a*b;


printf("\nYour salary for this week is:\n");


printf(" \n ***%f***\n",c);


system ("pause");


return 0;


}

Help with my C program. How do I ask the user whether they want to start again?
do a looping statement..





do{


/* you should place your codes here that you want to be repeated*/


do{


printf("do you want to try again? Y/N");


ans = getch();


}while(toupper(ans) != 'Y' %26amp;%26amp; toupper(ans) != 'N');


}while (toupper(ans)=='Y');





//make a variable ans
Reply:C has a powerful feature called recursion. (You may know that).





In the end of the program add


printf("Continue?(Y/N) :");


fflush(stdin); /* this is required. try without this */


opt = getch(); /* you must declare char opt */


if toupper(opt) = 'Y' /* #include %26lt;ctype.h%26gt; */


main(); /* this is recursion. main() is called inside main() */





Why do you use goto statements? They cause the system to abruptly jump. Use do while instead. (This loop executes at least once. If the answer matches the criteria, control is terminated out of the loop. Otherwise it loops again)


How long has this 1099-c debt elimination reporting been in effect?

I receive a letter from the IRS stating that I did not include $10,000 in my taxes from a 1099-c debt elimination from GMAC. I never owed them $10,000.

How long has this 1099-c debt elimination reporting been in effect?
What did you owe GMAC?





Clearly they think they loaned you money and you never paid the loan...because when they finally wrote the money off as non-collectible, they issued you a 1099-C. One copy went to the IRS and one copy got mailed to you at the last address they had for you.





From the government's point of view, not paying a loan back is economic income. You are required to include it income unless you are in bankruptcy or are insolvent by more than this amount.





The rules have been so static in this area, this year is the first time they've updated the publication since 1996.
Reply:You could try to google it ,here is some direct resource might be helpful.http://debt-consolidation.featured-resou...
Reply:Income from discharge of indebtedness has been a taxable item for decades.


Program using C++?

how do i write a program for this:





a program that reads in the coordinates of three points on a two-dimensional surface (a plane). Each point has an x-coordinate and a y- coordinate. Each point is given on a line by itself.


Thus your program's input will be something like:


------------------------------------


5.0 5.0


6.0 6.0


7.0 7.0


------------------------------------


The program computes the total distance involved in traveling from the first point (in this case 5.0,5.0) to the second point (6.0,6.0)


to the third point (7.0,7.0 in this case). It displays this distance on a single line:


------------------------------------


2.82843


------------------------------------








I need this asap (C++ programming file.. like one that produces the letter G,





#include %26lt;iostream%26gt;


using namespace std;





int main() {


cout %26lt;%26lt; "G";


return 0;


}





thanks in advance)

Program using C++?
#include %26lt;iostream%26gt;


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


using namespace std;


int main() {float n[6];


for(int i=0;i%26lt;6;i++) cin%26gt;%26gt;n[i];


cout%26lt;%26lt;sqrt(pow(n[0]-n[2],2)+


pow(n[1]-n[3],2)) +


sqrt(pow(n[2]-n[4],2)+


pow(n[3]-n[5],2));}








happy? :-D
Reply:/** SAY HELLO TO YOUR TEACHER FROM MEEE :) , I HATE *THEM :)


*THIS PROGRAM IS A COMPLETE WORKING TESTED ONE.


*WRITTEN ON VC++ 6.0


*YOU BETTER CHOOSE ME AS THE BEST ANSWER :))


**/


#include%26lt;iostream%26gt;


#include "math.h"





using namespace std;


using std::endl;





int main()


{


/**


*Read 3 inputs from standard input


*(keyboard, you can make it read


*from a file)


**/





/**


*You can define floating point variables if you want


**/


double x1=0; double y1=0;


double x2=0; double y2=0;


double x3=0; double y3=0;


double result=0;





cout%26lt;%26lt;"Please input x1 y1 x2 y2 x3 y3:"%26lt;%26lt;endl;


cout%26lt;%26lt;"Example: 2 3 5 6 3 5"%26lt;%26lt;endl%26lt;%26lt;"Input: ";


cin%26gt;%26gt;x1%26gt;%26gt;y1%26gt;%26gt;x2%26gt;%26gt;y2%26gt;%26gt;x3%26gt;%26gt;y3;





/**Calculation goes here


*double fabs (double x ),Computes absolute value of x


**/


result += sqrt(fabs(pow((x2-x1),2) + pow((y2-y1),2)));


result += sqrt(fabs(pow((x3-x2),2) + pow((y3-y2),2)));





cout%26lt;%26lt;endl%26lt;%26lt;"The result is: "%26lt;%26lt;result%26lt;%26lt;endl;





return 0;


}





MY EDIT FOR YOUR LOGICAL ERROR: The error is about you lazy, it works on my computer very well, i'm giving you a screenshot, check the code and see if you could correctly copied and pasted it. Syntax is an important thing you know right? or you don't even know how to copy it?And i assumed that you saved the file as xxx.cpp not xxx.c! one last thing if you are using a platform other than MS Visual C++, try changing #include "math.h" into #include%26lt;math%26gt; or #include%26lt;math.h%26gt;


otherwise the program is totally working here is the proof:


http://img81.imageshack.us/img81/2656/un...





EDIT FOR SMART AS S ADVISORS AND FOR THE LOSER that calls me a jerk: If a person is old enough to surf the web and ask questions,then he is old enough to know what is good and not good for himself. Take care you very wise smart-a ss advisors.
Reply:It can easily be done in one function.





have the first and second numbers as part of the function, as well as a third for the solution.





easy
Reply:you should try doing your own homework and THEN ask for help
Reply:Great. So some jerk gave you the answer. Which you will probably hand in, rather that work on it yourself. So then you realize you can't pass the exams, so you cheat on those too, if you can.





Then you take a job someplace, and you're that useless guy that can never do anything for himself. Always bugging the other engineers, asking questions, trying to get them to do your work for you.





After a while they'll get tired of you. If they're too nice to fire you, you get shuffled around to different teams, never moving upward, only sideways. Then one day the company gets acquired, and they use the reorganization as an excuse to boot you out the door.





What a depressing life you're going to have.





Why not develop some self respect? Be good to yourself, and start developing the skills that you're supposed to have when you graduate. Stop faking it and actually become someone who can do things. You'll be happy you did.


Programming using C++?

how do i write a program for this:





a program that reads in the coordinates of three points on a two-dimensional surface (a plane). Each point has an x-coordinate and a y- coordinate. Each point is given on a line by itself.


Thus your program's input will be something like:


------------------------------------


5.0 5.0


6.0 6.0


7.0 7.0


------------------------------------


The program computes the total distance involved in traveling from the first point (in this case 5.0,5.0) to the second point (6.0,6.0)


to the third point (7.0,7.0 in this case). It displays this distance on a single line:


------------------------------------


2.82843


------------------------------------








I need this asap (C++ programming file.. like one that produces the letter G,





#include %26lt;iostream%26gt;


using namespace std;





int main() {


cout %26lt;%26lt; "G";


return 0;


}





thanks in advance)

Programming using C++?
Okay, so currently the sum total of your programming abilities is to print a single letter to standard output. Frankly, the market for this skill is pretty thin.





I'd suggest doing this assignment yourself, and working on your problem solving skills. I'll give you one tip, though. The distance between two points in the plane is computed as





sqrt( (x0 - x1)^2 + (y0 - y1)^2 )





You'll have to turn that into valid C++, but once you get that working, the rest of the program should be very easy.





If you can't solve it, you may want to reconsider your choice of careers.
Reply:How much will you pay me for this?

flowering plum

C++ little problem?

I'm having problem with this piece of code:





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





#include %26lt;conio,h%26gt;











void main( )





{





int y=0, r=0, c=8;





do{





clrscr( );





printf(“value:”); scanf(“%d ”, %26amp;y);





if (y = = 0)





r = r+1;





}while(y%26lt;=100);





printf(“ r = %d”, r);





}





****


ok, now my question is:


does this determine:


a) counts the number of zeros entered in n numbers that are lower than 101


b) counts the number of zeros entered in n numbers that are lower than 100





really having trouble with this, already did many tests but can't get to a conclusion, any help would be greatly appreciated.

C++ little problem?
Look at this from your program:





while(y%26lt;=100);





What this means is that the code in the loop will execute when the condition is true. In this case, the condition is that y is less than or equal to 100. So, when y is 100 the loop will still execute. But that is it. It will not work past 100. That means that it will count the numbers until it gets to 100 -100 will be counted.





So a) is the correct answer.
Reply:Choice a is the answer.
Reply:Entering in 100 would not get counted but the loop continues.





Entering 101 would not get counted and the loop would stop.





I would say both answers are correct. But, to stop the loop A would be the answer.





bad question though...if they are trying to teach while loop condition stops. Bad bad....


Why is there an error in C?

#include "stdafx.h





int main(int argc, char* argv[])


{


int c;





c = getchar();


while (c != EOF) {


putchar(c);


c = getchar();


}


}








That is my code. when I run it, it shows an error. I use Microsoft Visual C++, Windows XP, and I am making a Console Application. A little help please...

Why is there an error in C?
you are missing a closing quote on the include





#include "stdafx.h"
Reply:getchar(); is an undeclared identifier. What do you want to do with getchar(); ? What will getchar be? A number, a letter, a string, what? Identify it. Just like int c; you need to indentify getchar(); - Without quotations it becomes a variable, but the variable is undeclared. When in doubt, find out what type of program you are making and look for it on the internet. You can find alot of C++ programming examples. Just type around. You'll find the answer. In C++, one error leads to another. Tip: Build your application after each line of code so that you may find your errors as you go along. Instead you are writing a program with errors from the start. When you fix one error, another will pop up. Start over and build from beginning. Don't just code away.
Reply:You are missing a closing speech mark (") on your first line, so C thinks your whole file is part of the filename to include! (You are probably getting an EOF error).





Maybe this is more what you want (I'm assuming your header file stdafx.h contains the standard input/output library stdio.h):





---





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





int main(int argc, char* argv[])


{


int c;





while ( (c=getchar()) != EOF) {


putchar(c);


}





return 0;


}





---





You might also find this website useful (I do):


http://www.cppreference.com/index.html
Reply:lets see my answer is....................... get a life
Reply:I think you selected the wrong options while creating your project.





Why don't you try creating a new project and then copy and paste your main into the new project, and then try running it. ( and add the header )





The steps for creating a project are:


-New Project


-select C++ , win 32 on left side and Win 32 Console project on the right side


-select location where to create , give name


-select Application Settings, click on Console and Empty,


-Finish











Oh, and another thing is that you don't have a return statement in your main. You always need to have a return statement in your main function!!!! Since, you said int main, your main should return an integer and so you could put something like a return 0; as the last statement in your main.





Hope this fixes your problem.
Reply:! = i think





see what happens...





if not take the damn P.C. back to the shop and tell them you are to thick to own a p.c.!





LoL! I wish you luck... i have not got a clue... cheers!





I guess you got Cods Heads there! hope these kind people help!


Anyone have friends that they don't include in....?

Let's say your just friends with someone who you get along with. You've introduced this person to your group of friends. you and your friends like this person yet you never include them in your plans. Why??? Is it b/c you assume they already have friends to hang with (if so, did you ever bother to ask) Anyone ever done this???

Anyone have friends that they don't include in....?
People do that sort of thing because they are not open to having new friends since they got so close to other people. They feel like they have enough and they don't want to talk to other people, which is wrong, but that is the way it is. I can tell you are going through something like this, and you should ask to hang out, wether they like it or not.
Reply:Thank you!!! Hopefully you have made some friends! Report It

Reply:i have friends like that. i consider them accquaintences and i enjoy hanging out at school with them. i have about 4 main friends and the rest i usually just hang with at school


Help with c++ program?

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


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


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


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


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


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


using namespace std;





int main()


{


char ans[20]= {'B','D','A','A','


C','A','B',


'A','C','D','B','C','D','A','


D','C','C','B','D','A'};


char studentans[3][20];


int identity[3][20];


int totalwrong[3];





for(int count1 = 0;count1%26lt;3;count1++)


{


for(int count2 = 0;count2%26lt;20;count2++)


{


do


{


cout%26lt;%26lt;"Person #"%26lt;%26lt;


(count1+1)%26lt;%26lt;" question #"


%26lt;%26lt;(count2+1)%26lt;%26lt;"- ";


cin%26gt;%26gt;studentans


[count1][count2];


studentans


[count1][count2] = toupper


(studentans[count1][count2]);


}


while(studentans[count1]


[count2] != 'A' %26amp;%26amp;


studentans[count1]


[count2] != 'B' %26amp;%26amp;


studentans[count1]


[count2] != 'C' %26amp;%26amp;


studentans[count1]


[count2] != 'D');


}


}

Help with c++ program?
The only problem is you aren't initializing the totalwrong array. Do this before you use it:





memset(totalwrong,0,sizeof(totalwrong)...

nil

C loop, giving me trouble !! Can anyone help..?

i have this code to test for palindromes, it functions perfectly well on the first test, but as the program continues to check for more after the first word it keeps printing not palindrome, once it wasnt the first word typed, run it pls, and you'll c what im talking about. Can anyone help me fix it..?








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


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


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





int isPalindrome( char *s);


int main (void)


{


int i=0;


int ch;


char s[100];


while (1){


while ((ch = getchar()) != ('\n')){


if (isalpha(ch)){


ch=toupper(ch);


s[i]=ch;


i++;


}


}


s[i]='\0';


if (isPalindrome(s) ==1){


printf("is palindrome\n");


}


else{


printf("not palindrome\n");


}


system("Pause");


return 0;


}

C loop, giving me trouble !! Can anyone help..?
What you are doing when you pass a char * into a function is essentially passing a pointer to the first char in the array.





This will always start with the first word you enter, and since you are storing all the strings on the same array, there is no way to delineate the different strings.





reseting the i to variable to zero after every call to isPalindrome()
Reply:You need a way to break out of your while(1) loop. Otherwise, you'll just keep asking for chars over and over again.





One way to do this is that if getchar() == \n you can call break;, which will break the outer loop.





A nicer way is to set a flag = true before you enter the main loop, and use while(flag)





then if the character is a carriage return, set flag to false, and the loop rops out naturally.
Reply:You need to initialize your index i in the loop:





while (1){


i = 0;


while ...





You'd be wise to ensure the user doesn't enter more than 100 characters, causing you to overrun your array s[100]. If this is just a toy program for an assignment, it may not matter. Still, it's good to get in the habit of writing robust code.