Congrats on completing the introductory section of Module 1! If not, go and complete it now. If done, give yourself a pat on the back.
Now, we'll learn the use of sizeof operator in CPP. This operator is a unary type--it takes only one operand as input and outputs the size in bytes of the operand.
You will be given four different variables of different data types: a (int), b (float), c (double), l (long long), d (string). Your task is to do step-wise operations as given below:
1. Divide b by c.
2. Divide b by a.
3. Divide c by a.
4. Add result at step 3 with l.
5. Print the sizeof(result) of each step in a single line. The outputs should be separated by spaces.
6. Print the sizeof(d) and sizeof(d) separated by a space.
First line of input conatins number of testcases T. For each testcase, there will be two lines of input. First line contains a, b, c, and l. Next line contains the string (single word).
For each testcase, print the required output as directed in steps.
Your task is to complete the provided function .
1 <= T <= 10
1 <= a, b, c <= 106
1 <= l <= 1018
1 2 3 5
4 8 4 8
b/c = 2/3 =>sizeof(2/3)=>float size is 4 bytes
b/a = 2/1 =>sizeof(2/1)=>double size is 8 bytes
c/a = 3/1 =>sizeof(3/1)=>integer size is 4 bytes
(c/a)+l =3+5= 8 =>sizeof(8)=>long long size is 8 bytes
sizeof(gfgc) = 32 => It is not 4 because of the reason listed here
sizeof(c) = 1 as it is just a character.
You can use sizeof for finding length of an array.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.