0% found this document useful (0 votes)
308 views

C Programming Quiz

This document contains multiple C programming questions and examples related to concepts like pointers, operators, file handling, data structures, and more. It includes full code snippets to demonstrate different programming concepts like pointer arithmetic, shift operators, logical operators, unions, file I/O, and more. It also contains multiple choice and fill in the blank questions to test understanding of C programming fundamentals.

Uploaded by

Siddarth Nyati
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
308 views

C Programming Quiz

This document contains multiple C programming questions and examples related to concepts like pointers, operators, file handling, data structures, and more. It includes full code snippets to demonstrate different programming concepts like pointer arithmetic, shift operators, logical operators, unions, file I/O, and more. It also contains multiple choice and fill in the blank questions to test understanding of C programming fundamentals.

Uploaded by

Siddarth Nyati
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

C PROGRAMMING

QUIZ
OUTPUT ROUND
#include<stdio.h>
void main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d\n",++*p + ++*str1-32);
}

Learning Outcome

Pointer Arithmetic, String Handling, ASCII, Pre-increment


Operator
#include <stdio.h>
int main()
{
int a = -12, b = 12;
a = a >> 3;
b = b << 3;
printf("\na = %d b = %d\n", a, b);
return 0;
}

Learning Outcome

Negative Number representation using 2s complement,


Right Shift Operator, Left Shift Operator
#include<stdio.h>
void main() {
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d\n", i, j, k, l, m);
}

Learning Outcome

Logical AND, Logical OR, Operator Precedence


#include <stdio.h>
int main()
{
int count = 5, a = 100;
do
{ printf ("a = %d count = %d\n", a, count);
a = a/count;
} while (count --);
return 0;
}
Learning Outcome

Do while, Integer Division, Divide by Zero Floating


Point Exception
#include <stdio.h>
int main() {
union values {
unsigned char a;
unsigned char b;
unsigned int c;
};
union values val;
val.a=1;
val.b=2;
val.c=300;
printf("%d,%d,%d",val.a,val.b,val.c);
}

Learning Outcome
Unions, Memory allocation
DUMBCHARADES ROUND
CONCEPT ROUND
How do you detect End of File when
you operate on files ?
Compilation is the process where a high
level language program gets converted
to machine language ( 1s and 0s ). How
does the conversion happen ?
How would you detect errors that occur
when we you execute a C program ?
These are not logical errors but errors
with library functions or system calls.
I have a text file. What would be most
efficient way to read the text file ? What
would your choice be and why ?
If you define a static variable and a local
( automatic ) variable in a function how
would they behave ? If the behavior is
different why is it so ?
DISTINGUISH ROUND
Declaration Vs Definition
Break Vs Continue
Structure Vs Union
Static vs Global Variable
Syntax Vs Semantic Errors
FILL IN THE BLANKS
ROUND
int main ()
{
int x = 5, y = 10;
printf(\nBefore calling swap function :
x = %d\ty=%d\n, x, y);
swap(___, ___);
printf(\nAfter calling swap function : x = %d\ty=%d\n, x, y);
}

void swap(___,___)
{
int temp;
temp = ___;
___ = ___;
___ = temp;
}
#include ______
#define ______
#define SQR(X) ____
int main()
{
#ifdef MACRO_ALLOWED
float y;
y = 225.0/SQR(15);
printf("\nThe value of y = ___\n", y);
#endif
}
#include <stdio.h> void sample() {
_______ sample();
void main() { _____ int total =
int i;
for ( i=0; i<= ____; i++ )
1;
{ total = total * 2;
sample();
} printf(____",
printf(The value of
total = %d, total)
total);
} }

Output =>
The value of total = 32
void main() {
int c, *b, __a, *d;
c = 4;
b = &c;
a = &b;
b = (int *)_____(sizeof(int));
*b = 2;
d = (int *)_____(b, 2*sizeof(int));
________("Answer =%d\n", c);
}
#include <stdio.h>
int main()
{
FILE *fpin, *fpout;
____ c;
fpin = fopen("input.txt", ____");
fpout = fopen("output.txt", ____");
____= fgetc(____);
while ( c!= ____ )
{
fputc(___, ___);
____ = fgetc(____);
}
return 0;
}
LOGIC ROUND
Searching for a pattern in
a text file
Sorting a list of numbers
Reading and writing to
the same file ( appending
data )
Merging 2 unsorted arrays
Searching for a string in a
sorted array
Splitting words from a
sentence based on
delimiter
Handling unexpected
events in functions
Handling unexpected
events in functions
Reversing a linked list
without using additional
space
Thank You

You might also like