Tutorial 3 Operators
Tutorial 3 Operators
Tutorial Sheets – 3
Software Development Fundamentals – I (15B11CI111)
Course Outcomes (CO)
CO1 Explain various phases of software development life cycle
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
Before attempting the following questions, discuss the doubts in earlier tutorials (Tutorial 1
and Tutorial 2), if any.
#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;
}
#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;
#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;
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. D2
B. Both D2 and D4
C. All declarations are valid
D. None of the listed options
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