NEW
Font size
S
M
L
XL
Worksheets13 dec 2023 SRMIST TRC MCA FN
Total questions: 15
Worksheet time: 15mins
Name
Class
Date
1.
#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.
#include<stdio.h>
int main(){
struct st
{
int i;
static int si;
};
struct st s = {1, 2};
printf("%d %d", s.i, s.si);
return 0;
}
a)
1 2
b)
Linker Error
c)
Runtime Error
d)
Compilation Error
3.
void main()
{
struct bitfields {
int bits_1: 2;
int bits_2: 9;
int bits_3: 6;
int bits_4: 1;
}bit;
printf("%d", sizeof(bit));
}
a)
2
b)
3
c)
4
d)
0
4.
#include<stdio.h>
int main()
{
struct leader
{
char *lead;
int born;
};
struct leader l1 = {"AbdulKalam", 1931};
struct leader l2 = l1;
printf("%s %d", l2.lead, l1.born);
}
a)
Compilation error
b)
Garbage value 1931
c)
AbdulKalam 1931
d)
None of the above
5.
#include<stdio.h>
struct employee{
char *company;
int salary;
};
int main(){
struct employee e, e1;
e.company = "CCC";
e1 = e;
printf("%s %s", e.company, e1.company);
return 0;
}
a)
Garbage value CCC
b)
CCC Garbage value
c)
CCC CCC
d)
Compilation Error
6.
#include<stdio.h>
int main(){
struct employee {
int empid[5];
int salary;
struct employee *s;
}emp;
printf("%d %d", sizeof(struct employee), sizeof(emp.empid));
return 0;
}
a)
6 4
b)
36 20
c)
32 20
d)
40 10
7.
#include<stdio.h>
#include<string.h>
struct player {
char pname[20];
}pl;
char* play(struct player *temp_pl){
strcpy(temp_pl->pname, "kohli");
return temp_pl->pname;
}
int main()
{
strcpy(pl.pname, "dhoni");
printf("%s %s", pl.pname, play(&pl));
return 0;
}
a)
dhoni kohli
b)
dhoni dhoni
c)
None
d)
kohli kohli
8.
#include<stdio.h>
struct TeamScore{
int wickets;
int score;
}ts = {2, 325};
struct country{
char *name;
}nation = {"India"};
int main()
{
struct TeamScore tcon = ts;
printf("%d %d %s", tcon.score, ts.wickets, nation.name);
return 0;
}
a)
325 2 India
b)
325 2 garbage value
c)
compilation error
d)
None of the above
9.
#include<stdio.h>
int main(){
struct sample{
int employees;
char comp[5];
struct founder{
char ceo[20];
}p; };
struct sample c = {4000, "CCC", "SN"};
printf("%s %d %s", c.comp, c.employees, c.p.ceo);
return 0;
}
a)
CCC garbage value garbage value
b)
CCC garbage value SN
c)
CCC 4000 SN
d)
CCC 4000 CCC
10.
#include<stdio.h>
int main(){
struct branch{
char bran[10] = "Bangalore";
int bpin = 431;
};
struct headoff{
char head[10];
int hpin;
};
struct headoff h = {"Chennai", 01};
struct branch b;
printf("HO - %s \n hpin - %d", h.head, h.hpin);
printf("BO - %s \n bpin - %d", b.bran, b.bpin);
}
a)
HO - Chennai hpin - 01 BO - Bangalore 431
b)
HO - Chennai hpin - 01
c)
Compilation Error
d)
Runtime Error
11.
#include<stdio.h>
int main(){
struct str{
int s1;
char st[30];
};
struct str s[] = { {1, "struct1"}, {2, "struct2"}, {3, "struct3"} };
printf("%d %s", s[2].s1, (*(s+2)).st);
}
a)
Compilation Error
b)
1 struct1
c)
2 struct2
d)
3 struct3
12.
#include<stdio.h>
int main(){
struct play{
char name[10];
int playnum; };
struct play p1 = {"virat", 18};
struct play p2 = p1;
if(p1 == p2)
printf("Two structure members are equal");
return 0;
}
a)
Compilation Error
b)
Two structure members are equal
c)
Nothing will be display
d)
Runtime Error
13.
#include<stdio.h>
int main()
{
struct check
{
}ck;
printf("%d", sizeof(ck));
}
a)
0
b)
1
c)
Compilation Error
d)
None
14.
#include<stdio.h>
int main()
{
struct check
{
int i:0;
}ck;
printf("%d", sizeof(ck));
}
a)
0
b)
2
c)
Compilation Error
d)
4
15.
#include<stdio.h>
int main()
{
struct num
{
int i, j, k, l;
};
struct num n = {1, 2, 3};
printf("%d %d %d %d", i, j, k, l);
}
a)
1 2 3 0
b)
1 2 3 4
c)
1 2 3 garbage value
d)
Compilation Error
Reset
