Tag Archives: C++

Function to Center Align Text in C++ Program

Though it is sim­ple and really intu­itive to align text in cen­ter of screen through C++ pro­gram, I found many new stu­dents are con­fused and keep look­ing for any built in func­tion. Thus, here I present the source code of func­tion that will cen­ter the text sup­plied in cen­ter of screen (horizontally).

func­tion centerText(char* s){

len=strlen(s);

int pos=(int)((80-len)/2);

for (int i=0; i<pos; i++)

   cout« “ ”;

cout«s;

}

Posted in C++, Examples, Source Codes, Tutorials & How Tos | Tagged C++, center align, cplus plus, example code, Source code, text | 9 Comments

C++ Tutorial and Online Ebook

There are flood of tuto­ri­als on C++ and Exam­ple source codes as well as sam­ple codes and videos. Today I’m refer­ring to a web­site ded­i­cated to C++ learn­ing – LearnCpp.com, ‘Tuto­ri­als to help you mas­ter C++ and object-oriented programming’.

This web­site is a com­plete online book as well. The site is divided into 18 chap­ters and an Appen­dix. The dif­fer­ence lies between an eBook and this site is that you can inter­act here but not in an eBook.

Con­tents

Chap­ter 0 Intro­duc­tion / Get­ting Started

0.1 Intro­duc­tion to these tutorials

0.2 Intro­duc­tion to pro­gram­ming languages

0.3…

Posted in References | Tagged C++, C++ Tutorial, eBook, Exam Preparation, Online Ebook | Leave a comment

Teacher’s Presentation PPT on C++ Classes [Download]

If you remem­ber, I’d pointed you to Ram Hari Regmi’s web­site for some C Pro­gram­ming lan­guage class Notes where he pub­lished 7 notes pdf files for free – Intro­duc­tion to C, Fun­da­men­tals of C, Input Out­put State­ments, Con­trol State­ments, Arrays, Func­tions, Struc­tures and Union. If you are inter­ested to down­load those 7 pdf files of class notes you can visit the link below:

http://icttrends.com/class-notes-on-c-programming-language.html

Today I’d like to point you to the same web­site where he has pub­lished Teacher’s Pow­er­Point Pre­sen­ta­tion files on C++ Classes.

Problem-Solving-The-Object-Of-Programming-Walter-Savitch

defining-c  -classes

example-code

example-code

structures

information-hiding

To down­load the Pow­er­Point file click the link below:

C++ Classes Presentation

Down­load

Posted in Downloads | Tagged C++, Classes, Download, ppt, Teacher's Presentation | Leave a comment

C++ Multiple Choice Questions Set 3

1. STL is based on which of the fol­low­ing pro­gram­ming paradigms?

a. Struc­tured Programming

b. Object Ori­ented Pro­gram­ming (OOP)

c. Func­tional Programming

d. Aspect Ori­ented Pro­gram­ming (AOP)

2. Which of the fol­low­ing cor­rectly describes the mean­ing of ‘name­space’ fea­ture in C++?

a. Name­spaces refer to the mem­ory space allo­cated for names used in a program

b. Name­spaces refer to space between the names in a program

c. Name­spaces refer to pack­ing struc­ture of classes in a program.

d. Name­spaces pro­vide facil­i­ties for orga­niz­ing the names in a pro­gram to avoid name clashes.

3. Which of

Posted in MCQ Bank | Tagged Answers, C++, MCQ, MCQ Bank | Leave a comment

C/C++ Video Tutorials for Beginners

Inter­net is a vast resource of free learn­ing mate­ri­als and what can be a more effec­tive to learn a prac­ti­cal topic like C/C++ pro­gram­ming? Obvi­ously video tuto­ri­als.

Most of us are using video shar­ing ser­vices like YouTube to share inter­est­ing video clips among friends. But it can’t be ignored that there exist some great con­tent in those ser­vices where the real genius peo­ple are con­tribut­ing to share the wealth of knowl­edge. These videos help

  • To learn what are the cur­rent var­i­ous prac­tices in programming.
  • Dif­fer­ent cod­ing Stan­dards among pro­fes­sional pro­gram­mers as well as new students.
  • Even if you

Posted in C++, References | Tagged C++, Video Tutorials | Leave a comment

C++ Multiple Choice Questions Set 2

C++ Mul­ti­ple Choice Ques­tions Set 1 was posted on Mon­day, June 7th, 2010 and is filed under Mul­ti­ple Choice Ques­tions. You can click here to go to Ques­tions of Set 1 and the Answers of Set 1.

Today, here are the twenty ques­tions for sec­ond set — C++ Mul­ti­ple Choice Ques­tions Set 2. Click here for the answers of this set.

1. The con­di­tional compilation

  1. It is taken care of by the compiler
  2. It is set­ting the com­piler option conditionally
  3. It is com­pil­ing a pro­gram based on

Posted in MCQ Bank | Tagged C++, MCQ, MCQ Bank, Objective Questions, Questions | 1 Comment

Source Code of Stack Data Structure

Down­load Stack Class Source Code stack.cpp

The day before, we talked about stack data struc­ture in http://data-structures-and-algorithms.psexam.com/stacks-data-structure/ regard­ing ‘What is data struc­ture?’, Stack Oper­a­tion, Uses of Stacks and Stack Rep­re­sen­ta­tion. We talked a lot on the­ory. The expla­na­tion is never com­plete with­out an exam­ple. Here is the code for a C++ class of stack data structure.

Fol­low­ing is the source code for stack class and a main func­tion to test if the class works well.

Stack Imple­men­ta­tion as a Class

# include<iostream.h>
#

Posted in Examples, Source Codes | Tagged C++, class, Data Structures, stack | 1 Comment

100 C/C++ Exam Questions

I have pre­sented fol­low­ing 100 ques­tions that were asked in dif­fer­ent exams from C/C++ chap­ter. It would take long to fin­ish answer­ing all these ques­tions and then pub­lish.  So, I pre­sented the ques­tions first and will go dig­ging for answers in com­ing posts, prob­a­bly. I’m plan­ning to cre­ate a small ebook of C++ Short Ques­tions and Answers. Will you help me by answer­ing these questions?

  1. What is vir­tual constructors/destructors?
  2. What is the dif­fer­ence between an object and a class?
  3. Why can’t we over­load the sizeof, :? , :: .,

Posted in Questions and Answers | Tagged C++, Introduction to C/C++, Questions, Questions and Answers | Leave a comment

Introduction to C/C++ Questions And Answers

Q.1. Who invented C pro­gram­ming lan­guage and when?

C pro­gram­ming lan­guage was invented by Den­nis Richie at Bell Tele­phone Lab­o­ra­to­ries in 1972.

Q.2. What were the pri­mary goals to develop C pro­gram­ming language?

C pro­gram­ming lan­guage was devel­oped pri­mar­ily as a sys­tem lan­guage, i.e. a lan­guage to write oper­at­ing sys­tems. The pri­mary goals were to:

  • pro­duce a min­i­mal­is­tic lan­guage that was easy to compile
  • allowed effi­cient access to memory
  • pro­duce efficient code
  • did not need exten­sive run-time support

Despite being a fairly low-level high level lan­guge, it was designed to encour­age machine and plat­form inde­pen­dent programming.

Q.3. Jus­tify “C and Unix

Posted in Questions and Answers | Tagged C++, Introduction to C/C++, Questions and Answers | Leave a comment

Multiple Choice Questions Set 1

This page lists 20 mul­ti­ple choice ques­tions from C++ cov­er­ing all the aspects of the lan­guage. Click here to go to the answers page for mul­ti­ple choice ques­tions set 1.

1. Which of the fol­low­ing lan­guages is a sub­set of C++ language?

A. C language

B. Java Language

C. C# language

D. B language

2. Which of the fol­low­ing cor­rectly describes C++ language?

A. Sta­t­i­cally typed language

B. Dynam­i­cally typed language

C. Both Sta­t­i­cally and dynam­i­cally typed language

D. Type-less language

3. Which of the fol­low­ing key­word sup­ports dynamic method resolution?

A. abstract

B. Vir­tual…

Posted in MCQ Bank | Tagged C++, Exam Preparation, MCQ, MCQ Bank, Objective Questions, Questions | 2 Comments