CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: Q1.write C++ program to accept a string and display ascii value letter by letter then display sum of all ascii values.
Q2.write C++ program to accept 20 nos and then display max & min.

Answer: 1. #include<stdio.h>
class str
{
char st[20];
};
void main()
{
str ob=new str();
int asc[20],sumasc=0;
printf("Enter string");
scanf("%s",ob.st);
for (i=0;i<20;i++)
{
asc[i]=toascii(ob.st[i]);
sumasc=sumasc+asc[i];
}
printf("The sum of ascii number is",sumasc);
}

2.Just read 20 numbers using for loop and then use one variable as maximum set to zero and in the for loop check the current number is larger then maximum if yes set that number to maximum else continue.



Category Object Oriented Programming in C++ Interview Questions & Answers - Exam Mode / Learning Mode
Rating (3.1) By 27 users
Added on 12/28/2013
Views 607
Rate it!
Question: Q1.write C++ program to accept a string and display ascii value letter by letter then display sum of all ascii values.
Q2.write C++ program to accept 20 nos and then display max & min.

Answer:

1. #include<stdio.h>
class str
{
char st[20];
};
void main()
{
str ob=new str();
int asc[20],sumasc=0;
printf("Enter string");
scanf("%s",ob.st);
for (i=0;i<20;i++)
{
asc[i]=toascii(ob.st[i]);
sumasc=sumasc+asc[i];
}
printf("The sum of ascii number is",sumasc);
}

2.Just read 20 numbers using for loop and then use one variable as maximum set to zero and in the for loop check the current number is larger then maximum if yes set that number to maximum else continue.
Source: CoolInterview.com

Answered by: Sasikumaran | Date: 1/23/2009 | Contact Sasikumaran Contact Sasikumaran

Q1).

# include <iostream.h>
# include <conio.h>

void main()
{
char * str;
char * temp;
int sum =0;
clrscr();
cout<< "Enter a String "<<endl;
cin >> str;

temp = str;

for(int i=0; temp[i] != ' Source: CoolInterview.com

Answered by: Govindaraj Jayaraman | Date: 4/10/2009 | Contact Govindaraj Jayaraman Contact Govindaraj Jayaraman

# include <iostream.h>
# include <conio.h>

void main()
{ int min,max,n;
int a[20];
clrscr();
cout <<"Enter a number how many you finw min & max
";
cin >> n;
cout << "Enter " << n << " Values
" ;
for(int i =0; i< n;i++)
cin >> a[i];

min = max = a[0];
cout << "List of number u have entered "<< endl;
for (i =0;i<n ;i++)
{
if(max < a[i])
{
max = a[i];
}
if(min > a[i])
{
min = a[i];
}
cout << a[i] <<"-->";
}

cout << "
Maximum values in list is :" << max << endl;
cout << "Minimum values in list is :" << min << endl;
getch();
} Source: CoolInterview.com

Answered by: Govindaraj Jayaraman Dharmapuri | Date: 4/10/2009 | Contact Govindaraj Jayaraman Dharmapuri Contact Govindaraj Jayaraman Dharmapuri


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
All the questions are compulsory. The first five questions shall be of 16 marks each and the last question shall be of 20 marks.

Q1. A. What is unary operator? List out the different operators
involved in the unary operator.

B. What is an adjust field format flag?

Q2. A. Distinguish between a # include and #define.

B. Can a list of string be stored within a two dimensional array?

Q3. A. Explain how a pointer to function can be declared in C++?

B. List the merits and demerits of declaring a nested class in C++?


Q4. A. What are the syntactic rules to be avoid ambiguity in multiple inheritence?

B. Explain the operation of overloading of an assignment operator.


Q5. A. Explain how the virtual base class is different from the conventional base classes of the opps.

B. Explain how an exception handler is defined and invoked in a Program.


Q6. A. What is a binary file? List the merits and demerits of the binary file usage in C++.

B. Write short notes on Text Manipulation Routines.

C. Write bites in Turbo c++ Header (?Include?) Files.









View Answer
Given an integer N>0,write a recursive c++ function that writes the integer 1,2,.......N ?
View Answer
Write a c++ programme in order to find the day you born,such that the programmer will take your birth date (day-month-year)?
View Answer
How can I make application program using c++, that means, execute as application that have setup and install on other computer run with out c++ compiler?
View Answer
How can i create a program in C++
which would input 5 random numbers, then it would arrange them in an ascending order, in descending order, from highest to lowest value and from lowest to highest value?
View Answer
Write programs using nested loops to produce the following design:
*
* * *
* * * * *
* * *
*
View Answer
plz tell how can i attach oracle database with c++?
View Answer
How to write a program to read sequences of integer from keyboard.program should sum all even and odd numbers?
View Answer
As an electric engineer choose a suitable electric engine to work in an electric metro. the power of engine is velated to the maximum speed of the metro as folloe:
0<v_max<=50km/hr. ip=0,5v_max^(2)
50<v_max<=100km/hr. ip=0,25 v_max^(2,5)+200
100<v_max. ip=2v_max^(3)
choose the suitable motor and state the corre speeding power of the motor.
View Answer
What is the object-oriented design,inheritance and dynamic polymorphism in c++?
View Answer
A positive integer entered through the keyboard. Write a function to obtain the prime factors of this number.
For example : prime factors of 24 are 2,2,2 and 3,, where as prime factor of 35 are 5
View Answer
When do we use abstract.h?Give an example with a small program.
View Answer
Write a program on abstract class.
View Answer
Write a C++ program that contains a structure named ?Student? having two data members

1) Name

2) CGPA
Declare array of structure ?Student? of size 10 .Populate this array by taking data from file inputFile.txt.File inputFile.txt contains Name and CGPA of the students for current semester. There is a single space between the Name and CGPA.

Display the un-sorted list of students on screen. Compare the CGPAs of all the students and sort Student List with respect to CGPA in ascending or descending order.

Display the sorted list of students, highest CGPA and lowest CGPA on screen and also write the result in File outputFile.txt with tab characters between the Name and CGPA.
Sample InputFile.txt
Ahmer 4.0

Aasim 3.5
Usman 3.4
Maria 2.4
Anila 3.0
Humza 2.6
Junaid 3.0
Talaal 3.8
Haris 3.9
Saira 2.6
Sample OutputFile.txt

Sample outputFile.txt





Name CGPA

===============

Maria 2.4

Humza 2.6

Saira 2.6

Anila 3.0

Junaid 3.0

Usman 3.4

Aasim 3.5

Talaal 3.8

Haris 3.9

Ahmer 4.0

===============

Highest CGPA = 4.0

Lowest CGPA = 2.4

































Sample output of screen:



Unsorted List of Students

Name CGPA

Ahmer 4.0

Aasim 3.5

Usman 3.4

Maria 2.4

Anila 3.0

Humza 2.6

Junaid 3.0

Talaal 3.8

Haris 3.9

Saira 2.6



Sorted List of Students

Name CGPA

===============

Maria 2.4

Humza 2.6

Saira 2.6

Anila 3.0

Junaid 3.0

Usman 3.4

Aasim 3.5

Talaal 3.8

Haris 3.9

Ahmer 4.0

===============

Highest CGPA = 4.0
Lowest CGPA = 2.4
View Answer
create six large matrices in subprogram (100*100) two static and three stack dynamic ...fill two static,two stack matrices with random numbers 1 to 100 ..the code in subprogram must perform large matrix multiplication on static matrices and should repeat this with stack dynamic ...compare and explain result?
View Answer
How can I set the background in flash like camera?( black color that some times for a specific time your background becomes white)
View Answer
HI, THIS PROGRAM MUST BE SUBMMITED AS SOON AS POSSIBLE.MAY YOU PLEASE HELP ME TO TACKLE IT ? I?LL BE VERY PLEASE IF I CAN GET HELP.





MULTICHOICE VIDEO RENTAL SHOP needs an Object Oriented program that process the following information about ten (10) videos in their stock
? The title, the director, the year produced and a list of main actors for each video. (If there are more than five main actors, include only the five most famous actors)
? The function setVideo that input information into each video object
? The function getVideo that displays information of a particular video on the screen
? A customer (identified by ID) plus his full names and address can borrow at most 2 videos @ R12.50 per day. A penalty of 10% per day is charged if returned late. The borrow period is at most 7 days
? Video titles should not exceed 25 characters in length. If that happens, truncate the length to a most 25 characters
? A video should be checked if is not rented out before borrow transaction is processed. If borrowed out the customer should either be requested for the second choice or be advised when the video is expected back in the shop
? Failure for the shop to receive the video back within 7 days, is considered permanent loss and the customer is liable to a R400.00 compensation fee
? Information about the number of films in stock at any point in time should be readily available
? At the end of business, a report should be generated showing
o Which films are rented out and when are they due
o To which customers they are borrowed to
o Which videos are left in stock
o How much money was collected for the day
Generate your own test data that will test all cases to illustrate the accuracy and consistency of your program

View Answer
what are the disadvantages of copy constructor??
View Answer
Can the structures contain the constructor?
If yes, then how?
View Answer
What is an object?


View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All Object Oriented Programming in C++ Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
"Holiday Packages" announced as an advertisement are an example of _________: (a) Offer (b) Counter Offer (c) Invitation to Offer (d) None of the above
A match fixing contract between a player and a broker is a: (a) Valid Contract (b) Unenforceable Contract (c) Void Contract (d) Illegal Contract
When a bookseller sells a book on cash payment then it is called as ___________: (a) Unilateral Contract (b) Bilateral Contract (c) Executed Contract (d) Executory Contract
____________ agreements are created by situation: (a) Written (b) Oral (c) Void (d) Implied
Cache = 0.031998 Seconds