Professional Documents
Culture Documents
Document59 SIVA
Document59 SIVA
19001353
Q1
#include <iostream>
int main() {
largest=n1;
else
largest= n2;
if(n3 >largest)
largest= n3;
Q2
#include <iostream>
int main()
int code;
switch (code)
break;
break;
break;
return 0;
Q3
#include <iostream>
using namespace std;
int main()
// (int argc, char** argv)
// The argc parameter represents the number of command line arguments.
// char *argv[] is an array of strings (character pointers) representing the individual arguments
provided on the command line.
// argc, or Argument Count, will be set to 4 (four arguments), and argv, or Argument Vectors, will be
populated with string pointers to "myprogram", "arg1", "arg2", and "arg3". The program invocation
(myprogram) is included in the arguments!
{
double units_consumed, bill;
float old_reading, new_reading;
if (units_consumed<=1000)
bill = units_consumed*0.05;
if (units_consumed>1000&&units_consumed<=2000)
bill = units_consumed*0.07;
if (units_consumed>2000)
bill = units_consumed*0.10;
cout << "The amount that you owe is: " << "RM" << bill << endl;
return 0;
}
Q4
#include <iostream>
using namespace std;
int main ()
{
int m_year,weight;
else if (weight >= 2700 && weight <= 3800 && m_year <= 1970)
{
cout<<"Your weight class is 2."<<endl;
cout<<"Your registration fee is RM25.50."<<endl;
}
else if (weight < 2700 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 4."<<endl;
cout<<"Your registration fee is RM27.00."<<endl;
}
else if (weight >= 2700 && weight <= 3800 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 5."<<endl;
cout<<"Your registration fee is RM30.50."<<endl;
}
else if (weight > 3800 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 6."<<endl;
cout<<"Your registration fee is RM52.50."<<endl;
}
Q5
#include <iostream>
int main()
int year ;
if (year % 100 == 0)
if (year % 400 == 0)
else
cout << year << "is not a leap year." << endl;
else
else
cout << year << "is not a leap year." << endl;
return 0;
SI
Q6
#include <iostream>
using namespace std;
int main()
int month ;
switch (month)
return 0;
}
Q7
#include <iostream>
using namespace std;
// Function to check quadrant
void quadrant(int x, int y)
{
if (x > 0 and y > 0)
cout << "lies in first quadrant";
Q8
#include <iostream>
int main()
char name[10];
if (hour>60)
else if (hour<=40)
cout << "Weekly wages: " << "RM" << wage << endl;
cout << "Contribution to Socso: " << "RM" << socso << endl;
return 0;
Q9
#include <iostream>
int main() {
int x,y;
char ch;
cin >> x;
cin >> y;
switch (ch) {
break;
break;
break;
break;
case 'r': cout << x % y;
break;
return 0;