Sie sind auf Seite 1von 2

CS 100 – Computational Problem Solving

Fall 2017-2018
Quiz 1

Time: 10 min Total Marks: 10

Name: SOLUTION

Roll Number:_______________________ Section:_____

Q1. Circle all the syntax errors in the following program: [4]

#include<iostream>

using namespace std;

int main ()
{

double hourly_wage;

cout>><<"Enter your hourly wage:";

cin>>hourly_wage;

double salary = hourly_wage*10;

cout<<"Your TAship salary is"<<Ssalary<<"Rs a week"<<endl;

return 0;
}
Note: Bad programming practices are not errors.

Q2. How much is the typical storage size of variable type int and float [2]

int 4 bytes, float 4 bytes


Q3. Correct the following program and write the output. 
 [4]

#include<iostream>

using namespace std;

int main ()

int price_item1 = 10;

int quantity_item1;

quantity_item1 = 15;

int total_price = quantity_item1*price_item1;

cout << "Total price of item 1: " << total_price << endl;

int price_item2 = 1;

int quantity_item2 = 1;

int total_price = total_price + price_item2*quantity_item2;

cout << "Total price of item1 and item 2: " << total_price << endl;

return 0;

total_price = 150

total_price = 151

Das könnte Ihnen auch gefallen