0% found this document useful (0 votes)
94 views2 pages

ESN-103 Computer Programming, IIT Roorkee

The document provides 10 questions related to computer programming concepts in C++. The questions cover topics like valid/invalid identifiers, order of operations, basic input/output, if/else statements, loops, functions, and arithmetic/logical operations. The questions would help assess a student's understanding of basic C++ programming constructs.

Uploaded by

Jithin Reddy N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views2 pages

ESN-103 Computer Programming, IIT Roorkee

The document provides 10 questions related to computer programming concepts in C++. The questions cover topics like valid/invalid identifiers, order of operations, basic input/output, if/else statements, loops, functions, and arithmetic/logical operations. The questions would help assess a student's understanding of basic C++ programming constructs.

Uploaded by

Jithin Reddy N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ESN-103 ; Computer Programming, IIT Roorkee

1. Which of the following are invalid identifiers:


(i) 13Greeting (ii) Intel1 (iii) Pentium 3 (iv) Pentium_4
(v) this (vi) %age (vii) no return (viii) I am Correct
Modify the invalid identifier such that it becomes a valid identifier, by adding,
removing, or modifying no more than 2 characters.
2. Identify whether the user defined identifiers or variables given below are valid or invalid. If
the identifiers or variables are invalid, give reasons for the same.
i) no-of-students ii) no_of_students iii) 1subject iv) iitr, v) rupees&paise,
vi) Float vii) int viii) x ix) y# x) $distance.
3. Write the display when each of the following C++ statements is executed. If nothing is
displayed then write “nothing”. Assume x = 2 and y = 3,z=4.
a) cout << x: b) cout << x + x; c) cout <<”x = “;
d) cout << “x = “ << x; e) cout << x + y << ” = “<< y + x;
f) z = x + y; g) cin >> x*2 >> y; h) // cout << “ x + y “<< x + y*z ;
i) cout <<”\n”;
4 Given the algebraic equation y = a x3 + 9, which of the following, if any, are correct C++
statements for this equation?.
a) y = a * x * x * x + 9; b) y = a * x * x * ( x + 9 ); c) y = ( a * x ) * x * ( x + 79);
d) y = (a * x ) * x * x + 9; e) y = a * ( x* x * x ) + 9;
f) y = a * x * ( x * x + 9 );
5. State the order of evaluation of the operation in each of the following C++ statements and
find the value of x after each statement is executed.
i. x = 9 + 3 * 8 / 2 – 1;
ii. x = 3 % 3 + 2 * 2 – 2 / 2;
iii. x = ( 3 * 9 * ( 3 + ( 9 * 3 / ( 3 ) ) ) );
6. What does the following code print?
cout << “*\n**\n***\n****\n*****”<< endl;
7..Find errors in the code segments below and if incorrect then fix them. Write the output
of the corrected code segment. You may directly copy these codes in files in Dev C++
and try fixing the code with the help of compiler.
(i)
#include <iostream
using namespace std
const double pi = 3.14159;
int main()
{
{
float length, width, area;
cout < "Enter The Length Of The Rectangle: ;
cin >> length;
cout << "Enter The Width Of Rectangle: ";
cin >> width;
area = = length*width;
cut <<"The area of the rectangle is : "<< area << endl;
return 0;
}
(ii)
#include <iostream.>
int main()
{
double side;
/get user input
cout<<"Please enter the length of the side : ";
cin>>radius;
/*act on user input /
if(side < 0.0) then
cout<<"Cannot have a negative side"<<endl;
else
cout<<"The area of the square is "<<side * side<<endl;
return 0
}
8. Write a program to calculate the compound interest.

9. Write a program to convert temperature from Fahrenheit to Celsius or Celsius to


Fahrenheit depending on the user choice.Use flag for user choice.

10. Write a program to check if one number is divisible by other.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy