LOOP: (TURBOc++)
Prg15: Write a program that displays a multiplication table for a given number.
Sample output: Enter a number: 3
Multiplication table for 3:
3 x 0 = 0
3 x 1 = 3
3 x 9 =27
PLEASE USE:
#include<stdio.h>
#include<conio.h>
scanf
printf
example:
#include<stdio.h>
#include<conio.h>
main()
{
int n=1, x=20;
clrscr();
printf("While Loop Example");
while (n<=5)
{
gotoxy(x, 3);printf(" %d", n);
n++;x=x+5;
}
getch();
}
LOOP: (TURBOc++)
PRG14. Write a program that will accept 10 numbers, identify if the number is odd or even, then finds the sum of all odd numbers, all even numbers, and total of all the numbers entered.
PLEASE USE:
#include<stdio.h>
#include<conio.h>
scanf
printf
example:
#include<stdio.h>
#include<conio.h>
main()
{
int n=1, x=20;
clrscr();
printf("While Loop Example");
while (n<=5)
{
gotoxy(x, 3);printf(" %d", n);
n++;x=x+5;
}
getch();
}
LOOP: (TURBOc++)
Prg16: Program that accepts a number then output the sum of the squares from 1 to n.
Enter a number : 4
1^2 + 2^2 + 3^2 + 4^2 = 30
PLEASE USE:
#include<stdio.h>
#include<conio.h>
scanf
printf
example:
#include<stdio.h>
#include<conio.h>
main()
{
int n=1, x=20;
clrscr();
printf("While Loop Example");
while (n<=5)
{
gotoxy(x, 3);printf(" %d", n);
n++;x=x+5;
}
getch();
}
a. Declare a single structure data type suitable for a car structure of the type illustrated:
Car Number
Miles Driven
Gallons Used
25 1450 62
36 3240 136
44 1792 76
52 2369 105
68 2114 67
b. Using the data type declared for Exercise 2a, write a C++ program that inter-actively accepts the above data into an array of five structures. Once the data have been entered, the program should create a report listing each car number and a miles per gallon achieved by the car. At the end of the report include the average miles per gallon achieved by the complete fleet of cars.
The Harris–Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise. This is called your basal metabolic rate, or BMR. The formula for the calories needed for a woman to maintain her weight is BMR = 655.1 + ( 9.563 × weight in kg ) + ( 1.850 × height in cm ) – ( 4.676 × age in years ) The formula for the calories needed for a man to maintain his weight is BMR = 66.5 + ( 13.75 × weight in kg ) + ( 5.003 × height in cm ) – ( 6.755 × age in years )
A typical chocolate bar will contain around 230 calories. Design an algorithm and write a program using switch case that allows the user to input his or her weight in kilograms, height in centimeters, age in years, and the character M for male and F for female. The program should then output the number of chocolate bars that should be consumed to maintain one’s weight for the appropriate sex of the specified weight, height, and age.
Write a function template named maximum() that returns the maximum value of three arguments that are passed to function when it is called. Assume that all three arguments will be of the same data type.
Create an abstract class 'Bank' with an abstract method 'getBalance'. $100, $150 and $200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC' are subclasses of class 'Bank', each having a method named 'getBalance'. Call this method by creating an object of each of the three classes
a,b,c = int user
x=\frac{-b+\sqrt{b^2-4ac}}{2a}
flowchart, pseudocode, c++