c++ problems for semester 1 BSCS, Exercises of Computer science

C++ problems to do exercises to enhance C++ advanced programing.

Typology: Exercises

2021/2022

Uploaded on 11/14/2022

abdul-salam-mubashar
abdul-salam-mubashar 🇵🇰

1 document

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Calculate the following formulas with C/C++ rules: 2 + 8 9, 6 3/4, 3/46, 6.03/4, 15%4 ?
a) 90,0,0,0,3 b) 74,4,0,4.5,3 c) 74,0,0,0.0,3 d) 74,0,0,4.5,2 e) 90,0,0,0.0,2
f) 74,0,0,4,3
2. What will be in ans1, ans2 after:
unsigned int a=5, b=0, c=11;
unsigned int ans1=!a||b&&c;
unsigned int ans2=!a||b&c;
a) 1,5 b) 7,0 c) 0,1 d) 11,5 e) 1,0 f) 0,0
3. If sizeof(int) is 4, then it is impossible that sizeof(long) gives:
a) 8 b) 64 c) 4 d) 2 e) 12 f) 128
4. What will be in a after:
int a,b=5;
a=++b+5;
a) 11 b) 55 c) undefined d) 10 e) 16 f) 0
5. What will be in a after:
int a,x=15,y=5;
a =(xy)&x >> 1;
a) 1 b) 5 c) 0 d) 155 e) 2 f) 1
6. What will appear on a display, if the following code is a part of some correct code, after
int j=5;
while(++j <9)
cout << j++ << ”,”;
a) 7 5 b) 8 6 c) 6 8 d) 5,7 e) 6,8,f) 5,7,
7. What will appear on a display, if the following code is a part of some correct code, after
char s=”I love cook\0ies..”;
s[9]=’r’;
cout « s « endl;
a) I love cook\0ies.. b) I love crok c) I love crok\0ies.. d) I love cork e) I love cok f) I love
cork\0ies..
1

Partial preview of the text

Download c++ problems for semester 1 BSCS and more Exercises Computer science in PDF only on Docsity!

  1. Calculate the following formulas with C/C++ rules: 2 + 8 9, 6 3 / 4, 3 / 4 6, 6_._ 0 3 / 4, 15%4?

a) 90 , 0 , 0 , 0 , 3 b) 74 , 4 , 0 , 4_._ 5 , 3 c) 74 , 0 , 0 , 0_._ 0 , 3 d) 74 , 0 , 0 , 4_._ 5 , 2 e) 90 , 0 , 0 , 0_._ 0 , 2 f) 74 , 0 , 0 , 4 , 3

  1. What will be in ans1, ans2 after: unsigned int a=5, b=0, c=11; unsigned int ans1=!a || b&&c; unsigned int ans2=!a || b&c;

a) 1 , 5 b) 7 , 0 c) 0 , 1 d) 11 , 5 e) 1 , 0 f) 0 , 0

  1. If sizeof(int) is 4, then it is impossible that sizeof(long) gives:

a) 8 b) 64 c) 4 d) 2 e) 12 f) 128

  1. What will be in a after: int a,b=5; a=++b+5;

a) 11 b) 55 c) undefined d) 10 e) 16 f) 0

  1. What will be in a after: int a,x=15,y=5; a = (x y)&x >> 1;

a) 1 b) 5 c) 0 d) 155 e) 2 f) 1

  1. What will appear on a display, if the following code is a part of some correct code, after int j=5; while(++j < 9) cout << j++ << ”,”;

a) 7 5 b) 8 6 c) 6 8 d) 5 , 7 e) 6 , 8 , f) 5 , 7 ,

  1. What will appear on a display, if the following code is a part of some correct code, after char s=”I love cook\0ies..”; s[9]=’r’; cout « s « endl;

a) I love cook\0ies.. b) I love crok c) I love crok\0ies.. d) I love cork e) I love cok f) I love cork\0ies..