a) 5*2%3+25/5
=(5 * 2) % 3 + (25 / 5)
=(10 % 3) + 5
= 1 + 5
= 6
b) a=5, b=6
! ((a<3) && (a==3) || (b>9))
= ! ((5 < 3) && (5 = = 3) || (6 > 9))
= ! ((0) && (0) || (0))
= ! ((0) || (0))
= ! (0)
= 1 / True
2) Identify the syntax errors in the following program:
include
mai()
{
float allowance=300.00 salary;
//input
cout<<"input salary=";
cin>salary;
salary=salary+allowance;
//output
cout<<"salary is="<
answer:
#include
main()
{
float allowance=300.00 salary;
//input
cout<<"input salary=";
cin>>salary;
salary=salary+allowance;
//output
cout<<"salary is="<
}
3) Write a program that calculate the monthly salary for an employes that where saturday & sunday are considered as non working days.
#include
main()
//declare variable
float no working days;
float salary per days;
float monthly salary;
//input 1
cout<<"no working days";
cin>>no working days;
//input 2
cout<<"salary per days";
cin>>salary per days;
//formula
monthly salary=working days*salary per days;
//output
cout<<"monthly salary="<
}
4) Write a program that calculate the average of 5 numbers that can be input by user.
#include
main()
float num1;
float num2;
float num3;
float num4;
float num5;
float total;
float average;
//input 1
cout<<"num1";
cin>>num1;
//input 2
cout<<"num2";
cin>>num2;
//input 3
cout<<"num3";
cin>>num3;
//input 4
cout>>"num4";
cin>>num4;
//input 5
cout<<"num5";
cin>>num5;
//formula 1
total=num1+num2+num3+num4+num5;
//output 1
cout<<"total="<
cout<<"average="<
}
5) Write a program that will calculate the area of rectangular, triangle and circle.
#include
main()
{
//declare variable
float height;
float width;
float area of rectangle;
float radius;
float area of circle;
float height;
float area of triangle;
//input 1
cout<<"height";
cin>>height;
//input 2
cout<<"width";
cin>>width;
//input 3
cout<<"radius";
cin>>radius;
//input 4
cout<<"height";
cin>>height;
//formula 1
area of rectangle=height*width;
//output 1
cout<<"area of rectangle="<//formula 2
area of circle=3.14*radius*radius;
//output 2
cout<<"area of circle="<//formula 3
area of triangle=0.5*height*height;
//output 3
cout<<"area of triangle="<return 0;
}
No comments:
Post a Comment