Write a countdown program which prints numbers from 50 to 25
Solution
6) Program is in C++
#include <iostream>
using namespace std;
int main()
{
for(int count=50;count>=25;count--) // We want to print from 50 to 25
{
cout<<count<<endl; // Print the count and give a new line
}
// For loop will be terminated once count reaches to 24 hence we have to print \"goodbye\" after that
cout<<\"goodbye\";
// here we can give newline character as well if we want the cursor to point to newline after printing
retunr 0; // return 0 to as return value for the main function
}
7) In this question we are given two structures ass below
Struct BrandInfo
{
String company;
String model;
}
and
Struct Disktype
{
Brandinfo brand;
float capacity;
}
Then DiskType myDisk; // myDisk variable of Structure DiskType is decclared
and myDisk has 1 variable which is a Brandinfo Structure and another variable is float
Now
A) myDisk.capacity = 1.44 [VALID]
explanation : It has assigned a float value 1.44 into the memory allocated for variable capacity within the memory block of DiskType structure hence it is perfectly fine.
B) myDisk.BrandInfo = \"memorex\" [INVALID]
explanation : myDisk structure has a variable \"brand\"of Structure type \"BrandInfo\" but in the current context it is trying to assign a value to a TYPE (here it is Structure Brandinfo) but not the variable and which is incorrect. Correct thing will be to assign a value to a variable not the Structure. And if the variable is a structure then one should assign the value per each component.
C) myDisk.brand = \"memorex\" [INVALID]
Explanation : This is a incorrect statement since here we are trying to assign a value to a variable \"brand\" of structure \"BrandInfo\" which in-tern has 2 components called company and model. So correct thing is to assign the value per each component of variable \"brand\" of structure type \"BrandInfo\"
D) [Invalid] based on above explanation
Please let me know if more explanation is needed.

