0% found this document useful (0 votes)
69 views5 pages

Data Types and Program Outputs Analysis

Uploaded by

Dhairya Pandey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views5 pages

Data Types and Program Outputs Analysis

Uploaded by

Dhairya Pandey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ODD 2023

Tutorial Sheets – 3
Software Development Fundamentals – I (15B11CI111)
Course Outcomes (CO)
CO1 Explain various phases of software development life cycle

CO2 Explain various data types, memory allocation schemes, precedence of


arithmetical and logical operations, and need of array, and structures
CO3 Draw the flow chart and write the high level code for different problems

CO4 Apply and implement functions with or without pointers for different problems

CO5 Demonstrate and implement various operations like traverse, insertion, deletion,
etc. on files

Note: Students are advised to submit their solutions to their respective


tutorial faculties

Before attempting the following questions, discuss the doubts in earlier tutorials (Tutorial 1
and Tutorial 2), if any.

Q1. [CO2] What will be the output of following program?

#include<stdio.h>
int main()
{
printf("%d\t",sizeof(2.5));
printf("%d\t",sizeof(2));
printf("%d\t%d",sizeof('A'),'A');
return 0;
}

Q2. [CO2]What will be the output of the following program?

#include<stdio.h>
int main(){
float me = 5.25;
double you = 5.25;
if(me == you)
printf("Hey");
else
printf("Bye");
return 0;
}
Q3. [CO2] What will be the output of the following program?
#include <stdio.h>
int main()

{
int a=11, b=22, c;

c = a + b + a++ + b++ + ++a + ++b;


printf("a=%d",a);
printf("b=%d",b);
printf("c=%d",c);

Q4. [CO2] Show the output of the following code:

#include <stdio.h>
int main() {
char ch = 'B';
printf("%c\n", ch);
int x = 45, y = 90;
printf("%d\n", x);
printf("%i\n", y);
float f = 12.67;
printf("%f\n", f);
printf("%e\n", f);
int a = 67;
printf("%o\n", a);
printf("%x\n", a);
char str[] = "Hello World";
printf("%s\n", str);
printf("%20s\n", str);
printf("%-20s\n", str);
printf("%20.5s\n", str);
printf("%-20.5s\n", str);
return 0;
}
Q5. [CO2]Which one of the following operator performs operations with only integer operands?

A. +
B. *
C. /
D. %
Q6. [CO2] Which one of the following statements are true in context of || (logical OR) operator

S1: Evaluation of the expression involving || operators only will stop if one of its components
is evaluated as true
S2: Evaluation of the expression involving || operators only will stop if one of its components
is evaluated as false
S3: Evaluation of the expression involving || operators only takes place from right to left
S4: Evaluation of the expression involving || operators only takes place from left to right

A. S1 & S2
B. S1 & S3
C. S1 & S4
D. None of the listed options

Q7. [CO2] Which one of the following is the output of the program given below?

#include<stdio.h>
void main()
{
int A = - -2
printf(“%d”, A);
}

A. -2
B. 2
C. Will give error
D. None of the listed options

Q8. [CO2] Which one of the following is the output of the program given below?

#include <stdio.h>
int main()
{
int x, y, z;
x = 20;
y = 30;
z = 10;

if(x > y, x > z)


printf("IF BLOCK");
else
printf("ELSE BLOCK");
return 0;
}
A. IF BLOCK
B. ELSE BLOCK
C. Will give error
D. None of the listed options

Q9. [CO2] Which one of the following is the output of the program given below?

#include <stdio.h>
int main()
{
intw, x, y, z;
x = 20;
y = 30;
z = 10;
w = (x = z, y+=x, z = x+y+z);
printf(“%d %d %d %d”, w, x, y, z);
}

A. 60, 10, 40, 60


B. 10, 10, 40, 60
C. 10, 10, 30, 60
D. None of the listed options

Q10. [CO2]Which one of the following is not a valid declaration of a variable in C?


D1: signed int x;
D2: unsigned short y;
D3: unsigned short int z;
D4: signed short w;

A. D2
B. Both D2 and D4
C. All declarations are valid
D. None of the listed options

Q11. [CO2] What will be output of the following program?

int main()
{
float w, x;
double y, z;
w = 20 / 3;
x = 20.0 / 3;
y = 20 / 3;
z = 20.0 / 3;
if(w == y)
printf(“Same”);
else
printf(“Different”);
if(x == z)
printf(“\t Same”);
else
printf(“\t Different”);
if(w == x)
printf(“\t Same”);
else
printf(“\t Different”);
return 0;
}

A. Same SameSame
B. Same DifferentDifferent
C. Different SameSame
D. Different DifferentDifferent

Common questions

Powered by AI

Memory allocation schemes, such as static and dynamic allocation, impact performance; static allocation is fast and efficient because memory is allocated at compile time, reducing run-time overhead. However, dynamic allocation offers flexibility and can better handle memory requirements, though it incurs more runtime cost and potential fragmentation issues .

Using format specifiers like '%c', '%d', '%f', '%e', '%o', '%x', and '%s' allows different representations of data types for output. They control display format (decimal, hexadecimal, octal, exponential, fixed-point) and alignment (width and alignment in strings) to ensure correct and formatted output, thereby aiding readability and precision in output presentation .

The logical OR operator '||' utilizes short-circuit evaluation, meaning it stops evaluation as soon as one of its components is true. This demand-driven evaluation saves computational resources, as determining a true outcome does not depend on the subsequent conditions, aligning with S1 and S4 statements being correct .

The key phases of the software development life cycle as described in the course outcomes include defining the various phases which could involve planning, analysis, design, implementation, testing, deployment, and maintenance .

Double negation (two minus signs) effectively cancels the negative operation, resulting in a positive integer. Hence, the output for 'int A = - -2' is 2, as the syntax is equivalent to 'int A = 2'. This highlights how unary operations adjust value signs .

The operator precedence affects the evaluation order, where '+' has left-to-right associativity and increments (either postfix or prefix) affect the value used and assigned afterward. Here, the increments applied to 'a' and 'b' alter their interim values during calculation, affecting the final result of 'c' .

Different declaration types impact how much memory is allocated; 'signed' and 'unsigned' affect integer range, 'short' and 'int' change size boundaries. These variations optimize memory usage and efficiency, with all declarations D1 to D4 being valid, offering flexibility in resource constraint settings .

Expressions using comma operators evaluate each expression sequentially, only returning the result of the last part. Here, "x > z" is the crucial decision check because it is the final operand after "x > y". Hence, even if "x > y" is false, "x > z" returns true, leading to 'IF BLOCK' depending on the final logical check .

The code yields "Bye" because of the difference in precision between 'float' and 'double'. When 'me', a float, is always compared to 'you', a double, due to precision loss in conversion, they might not be considered equal in memory representation, thus the 'else' block executes .

The 'modulus' operator (%) is used to find the remainder in division operations. It is unique because it specifically operates on integer operands and cannot be used directly with floating-point numbers, unlike other arithmetic operators that can handle both integers and floats .

You might also like