Tutorial - 2
Tutorial - 2
Tutorial Sheets – 2
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
1. What is the correct value to return to the 4. What punctuation ends most lines of C++
operating system upon the successful code?
completion of a program? A. .
A. -1 B. ;
B. 1 C. :
C. 0 D. '
D. Programs do not return a value.
5. Which of the following is a correct
2. What is the only function all C++ comment?
programs must contain? A. */ Comments */
A. start() B. ** Comment **
B. system() C. /* Comment */
C. main() D. { Comment }
D. program()
6. Which of the following is not a correct
3. What punctuation is used to signal the variable type?
beginning and end of code blocks? A. float
A. { } B. real
B. -> and <- C. int
C. BEGIN and END D. double
D. ( and ) 7. Which of the following is the correct
operator to compare two variables?
A. :=
B. = printf("%i\t%i\t%i\t%i\n", 72, 072, 0x72,
C. equal 0X72);
D. == printf("%d\t%c");
}
Q8. Identify & correct errors in following
statements: Q10. Give the output of following print
a. int a=10, int b=20; statements:
b. int a=10, float b=2.5; (a) printf(“%05d,%5d,%-5d”, 32,32,32 );
c. const int number = 100; (b) printf(“%6.3f,%06.3f,%09.3f,%-09.3f,
number=500; %6.0f,%6.0f”, 45.6, 45.6, 45.6, 45.6, 45.4,
d. Printf(“To err is human”); 45.6 );
e. Printf(1,2,3); (c) printf("int: %d, char: %c, double: %lf\n",
f. int b = 2f; 5, '*', 5.0);
(d) printf("you got %d%% in the exam\n",
Q9. What will be the output of following C 100);
programs? Give explanation.
Q11. #include<stdio.h>
(a)#include<stdio.h> int main()
main() {char ch;
{ int i;
int a,b ; scanf("%c", &i);
printf("Enter two numbers"); scanf("%d", &ch);
scanf("%d%d",&a,&b); printf("%c %d", ch, i);
printf("%d + %d = %d\n",a,b,a+b); return 0;
printf("%d / %d = %d\n",a,b,a/b); }
printf("%d * %d = %d\n",a,b,a*b);
printf("%d %% %d = %d\n",a,b,a%b); Q12. #include<stdio.h>
} int main()
{
(b)#include<stdio.h> float fval=7.29;
main() printf("%d\n", (int)fval);
{ return 0;
printf("%d\t%d\t%d\t%d\t%d\n", 72, 072, }
0072, 0x72, 0X72);
printf("%d\t%c\n",'A','A');
printf("%d\t%o\t%x\n",72,72,72);