C++ Programming Exercise

Please download to get full document.

View again

of 16
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Document Description
Solved exercises and assignments and test questions
Document Share
Document Transcript
  Page 1  of 16   SECRET BEHIND C++ Never afraid for such codes …………. again LPWIN32_FIND_DATA FindFirstHelper::ResetFindData(){ if(findData == NULL) {findData = new WIN32_FIND_DATA;} else{::FindClose(findFirstHandle); } return findData; }  bool FindFirstHelper::FindFirst(const char *filePattern){ ResetFindData(); #if 0 // gmc revist: we should handle UNC filenames here as well string UNCAware = "\\\\?\\"; UNCAware += filePattern; findFirstHandle = ::FindFirstFileW(UNCAware.c_str(), findData); #else string UNCAware = filePattern; findFirstHandle = ::FindFirstFileA(UNCAware.c_str(), findData); #endif Practical approach Solved exercises and assignments and test questions BY Musa Mustapha  Page 2  of 16   To get A++ is Easy If conditional statement syntax sample #include <iostream> // header file for cin and cout #include <string> // header file for character #include <conio> // header file for getch , to retain the result on screen int main ( ) //   It tells where the program begins   { //  opening braces char answer; // declaration cout<<” do you have problem with c++ ”<<endl;  cin>> answer; // input from user    if    ( answer==‟yes‟ )  //  conditional statement cout<<” this is the right solution to you <<endl; //  it will display this else // if the 1st condition fails then it will execute this statement cout<<”keep it aside”<<endl;  getch ( ); // to retain the result } // closing braces Caution! Whenever you see double slash like this // means a comment or an explanatory statement for you to understand, it does not have an effect of the execution of the program  Page 3  of 16   Learn a programming in 1 hour a day Prefatory I purposefully compose this solutions to our dear colleague’s  problem from other department, who petrified of C++ course, going by the last test most of us already forecast our result in programing and found likely to be below average. This minuscule pages will give you an understanding, a good grade in programming course. I surprise why our colleagues from other department afraid of programming, it is too simple and very elementary at this stage, may be the tricky is most of us dearth the practical aspect or terrified of computer operating. Moreover, most of us find this course as invaluable to our studies especially EMT and Mathematics students. I learnt that you misunderstood the course as a result of deficiency of familiarity in application of programming into your major. Nowadays, computer has become part of human being activities, no organisation, academic or any field can do without computer, therefore possession of computer knowledge can helps us in one way or the other in future time. However, it wasn’t too late for you to earn a very good grade in Jungle++, at least you have an outstanding time toward examination for you to earn a good grade at least a “A” or “B+” in programming problem . C++ does not required a much computational experience nor mastering an equations, it only need understanding of the concept behind the scene . So now it’s time to blast the secret behind the scene, that’s why , I intent to summarised the basic area covered from the courseware and solve an assignments, lab exercise and test questions, so that it will support us in our study toward imminent examination by the grace of Allah. Please do not depend on this material purposely for an examination, this passage is based on practical approach, you must read the theoretical  Page 4  of 16   aspect for you to understand this clearly. And for those who are interested in more practical aspect, we may likely hold general revision class on programming, which scheduled as follows, firstly, practical aspect and secondly, resolve indistinct theory then answer some skeptical question relevant to an examination, on a day before C++ examination. Please do test run the programs in your computer to ensure it credibility, because I drafted them off head, due to time factor I cannot able to summarize the whole courseware, I will only solve the exercises and test questions. Lastly, I am not blameable for any offence you bump into by wronging with this texts either by jotting, recording, snapping, tearing or whatever mean of transmission you use to constrain malpractice. Week 1 exercise Lab Questions Q1. Identify any real world problem and provide a suitable solution using your knowledge of problem solving methodology. Solution to the Problem of drafting multiplication table #include <iostream> #include <iomanip> #include <conio> //  program to generate multiplication table using for loop nested statement int main ( ) { int row , column; for (row=1; row<=12; row++) { for (column=1;column<=12;column++) { cout<<setw(5)<<row*column; } cout<<endl; } getch ( ); } This will be the output of the above program.  Page 5  of 16   Week 2 exercise Lab Questions Q1. Write a program that will prints the following x` shape: * * * * * * * * * * * * * Solution #include <iostream> #include <conio> //  program to display the shape of x; int main ( ) { cout<<”  * * “<<endl;   cout<<”  * * “ <<endl; cout<<”  * * “ <<endl; cout<<”  * “ <<endl; cout<<”  * * “ <<endl; cout<<”  * * “ <<endl; cout<<”  * * “<<endl;  getch (); }
Search Related
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks