Sie sind auf Seite 1von 4

Reg.No.

MANIPAL INSTITUTE OF TECHNOLOGY


MANIPAL, KARNATAKA, INDIA

FIRST YEAR B.TECH (ALL BRANCHES) - ASSIGNMENT #1

COURSE: PROBLEM SOLVING USING COMPUTERS (CSE 1001)


(Regulation 2014)
28.08.2017-01.09.2017

Duration: 15 Minutes MAX.MARKS: 06

Instructions to Candidates:

 All questions carry equal marks. This assignment will be a closed book one.
 No formula sheet will be provided however students shall use scientific
calculators.
 Only one full question to be answered by a student as assigned by the faculty

1 a) With neat block diagram of a computer explain the functions of CPU detailing its (2M)
functional units?

1 b) Write an algorithm to check whether the given year is a leap year or not? (2M)
1 c) Write a complete C++ program to generate the following output pattern (2M)

1
3*2
4*5*6
10*9*8*7
11*12*13*14*15

2 a) What is system software? Brief about the different categories of computer (2M)
languages?

2 b) Write an algorithm to check whether the given positive integer number is a perfect (2M)
number or not?

CSE 1001 Page 1


2 c) Write a complete C++ program to generate Fibonacci series for a given range? (2M)
3 a) Explain the different types of computational problems with suitable example? (2M)
3 b) Justify the reason why conditional operator is also called as ternary operator? (2M)
Convert the below code snippet using conditional operator?

if(a>b)
if(a>c)
cout<<” a”;
else
cout<<”c”;
else
if(b>c)
cout<<”b”;
else
cout<<”c”;

3 c) Write a complete C++ program to read a number and check for the following (2M)
operations using a while Loop.

 Display “EVEN” if all the digits in the number are even.


 Display “ODD” if all the digits in the number are odd.
 Display “neither EVEN nor ODD” if all the digits in the number
are neither even nor odd.

4 a) What is a variable? Give the rules for valid variable names? (2M)
4 b) What is operator precedence and associativity? Resolve the expression stepwise to (2M)
obtain the final value of x. int x=(-10*(2-3)/15%(5+7)+8*6/12);

CSE 1001 Page 2


4 c) Find the output for the following error free code (2M)
#include<iostream>
using namespace std;

int main(){

int i=2, n, j;

for (n=5; i<n; i++)

for(j=2; j<=4; j++)

{ if (j%2 != 0)

continue;

cout<<i<<"*"<<j<<"="<<i*j<<endl;

if (i % 3 == 0)

break;

}
5 a) Explain the use of typecast operator with a suitable example? (2M)
5 b) Convert the following switch structure to its equivalent if - else if - else structure. (2M)
switch(ch)
{
case 1: cout<<”one”; break;
case 2: cout<<”two”; break;
case 3: cout<<”three”; break;
case 4: cout<<”four”; break;
case 5: cout<<”five”; break;
default : cout<<” one to five”;
}

CSE 1001 Page 3


5 c) Write a C++ program to accept and add the integer numbers entered by the user (2M)
and display the sum of entered numbers when 0 is entered.
6 a) Explain the integer and float datatypes with a valid examples? (2M)
6 b) Considering a, b, c, x, y, z, zz as float values compute the values of x, y, z and zz (2M)
if a=9.0, b=12.0, c=3.0?

x=a + b/3+c*2-6;

y=a + b/(3+c)*(2-5);

z=a-(b/(3*c)*2)-4;

zz=(x + y )/z+2;

6 c) Write complete C++ program using both i) nested if and (ii) else if ladder control (2M)
structures to calculate the commission for the input value of sales.
1. Commission is NIL for sales amount <= 5000 for females and for males
commission is 2% for sales amount <=5000.
2. Commission is 2% of sales when sales amount is more than Rs. 5000 for
females and for males it is 4%.
3. Commission is 6% for sales amount > Rs. 10,000 for both males and
females.

CSE 1001 Page 4

Das könnte Ihnen auch gefallen