You are on page 1of 3

PROBLEM SOLVING TECHNIQUES USING C – S11BLH12

ASSIGNMENT

I. MCQ [1 x 5 = 5]

1. Which of the following are themselves a collection of different data types?


a) String
b) Structure
c) Char
d) All of the mentioned

2. What is the size of a C structure.?


A) C structure is always 128 bytes.
B) Size of C structure is the total bytes of all elements of structure.
C) Size of C structure is the size of largest element.
D) None of the above

3. What would be the size of the following union declaration? (Assuming size of double = 8, size of
int = 4, size of char = 1)
#include <stdio.h>
union uTemp
double a;
int b[10];
char c;
}u;

a) 4
b) 8
c) 40
d) 80

3. What will be the output of the following C code (Assuming size of int and float is 4)?

#include <stdio.h>
union
{
int ival;
float fval;
} u;
void main()
{
printf("%d", sizeof(u));
}
a) 16
b) 8
c) 4
d) 32

5. fwrite() can be used only with files that are opened in binary mode.

a) true
b) false

II. ANSWER THE FOLLOWING [2 X 5 = 10]

1. What will be the output of the C program?

#include<stdio.h>
int main()
{
struct simp
{
int i = 6;
char city[] = "chennai";
};
struct simp s1;
printf("%d",s1.city);
printf("%d", s1.i);
return 0;
}

A. chennai 6

B. Nothing will be displayed

C. Runtime Error

D. Compilation Error

2. Differentiate between structure and union with relevant example


3. Write down the syntax for declaring the union
4. Derive a structure declaration for collecting student’s basic details.
5. Write a C program to calculate the size of the structure using sizeof() operator.

III. ANSWER THE FOLLOWING [1 x 10 = 10]


1. Develop a C program to find the area of sphere by passing structures to a function

You might also like