[go: up one dir, main page]

0% found this document useful (0 votes)
494 views2 pages

PPS Lab Quiz

This document contains 10 multiple choice questions about C programming concepts like functions, operators, arrays, pointers, macros, static variables etc. along with sample code snippets to demonstrate each concept. The questions cover a variety of fundamental and intermediate C programming topics that would be included in an introductory programming lab assessment.

Uploaded by

pandey1812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
494 views2 pages

PPS Lab Quiz

This document contains 10 multiple choice questions about C programming concepts like functions, operators, arrays, pointers, macros, static variables etc. along with sample code snippets to demonstrate each concept. The questions cover a variety of fundamental and intermediate C programming topics that would be included in an introductory programming lab assessment.

Uploaded by

pandey1812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Computer Science & Engineering

CS102 Programming for Problem Solving Lab

Class: B.Tech. (CSE) Section: C Session: SP/19


Roll No: Name:

1. What will be output when you will execute following c code?


#define PRINT printf ("Star Wars"); printf (" Psycho");
#include<stdio.h>
Void main () {
int x=1;
If(x--)
PRINT
Else
Printf ("The Shawshank Redemption"); }

(A) Stars Wars Psycho (C) Warning: Condition is always


true
(B) The Shawshank Redemption (E) Compilation error
2. What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int a=10;
if(printf("%d",a>=10)-10)
for(;;)
break;
else; }

(A It will print nothing (C) 0


(B) 1 (E) Compilation error

3. What would be the output of the following program, if the array begins at address 1200?
Main()
{ int arr[]={2,3,4,1,6};
Printf(“%d%d”, arr, sizeof(arr)); }
Ans-----------------------

4. What would be the output of the following program?


Main ()
{Char a[]= “C program”;
Char *b= “C program”;
Printf(“%d%d\n”, sizeof(a), sizeof(b));
Printf(“%d%d\n”, sizeof(*a), sizeof(*b));
}
Ans-----------------------

5. What would be the output of following program?


Main()
{ char str1[]= “Hello”;
char str2[]= “Hello”;
if(str1==str2)
printf(“\n equal”);
else
printf(“\n unequal”);
}
Ans------------------
6. What will be the output of the following C program segment?
char inchar = 'A';
switch (inchar)
{
case 'A' :
printf ("choice A \n") ;
case 'B' :
printf ("choice B ") ;
case 'C' :
case 'D' :
case 'E' :
default:
printf ("No Choice") ; }
Ans------------------

7. Consider the following C function:


int f(int n)
{
static int i = 1;
if (n >= 5)
return n;
n = n+i;
i++;
return f(n);
}The value returned by f(1) is
Ans------------------

8. Point out error, if any, in the following function.


main ()
{ int b;
b= f(20);
printf(“%d”, b); }
Int f (int a)
{ a>20? return (10): return (20) ;}
Ans------------------

9. What would be the output of following program?


#define SQR(x) (x*x)
Int main ()
{ int a, b=3;
a= SQR(b+2);
printf(“\n%d”,a); }
Ans------------------

10. What would be the output of following program?


Main ()
{inc(); inc(); inc(); }
Inc()
{Static int x;
Printf(“%d”, ++x); }
Ans------------------

You might also like