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

Tutorial Sheet

The document is a question bank for programming and data structures, primarily focused on C programming challenges. It includes a variety of tasks such as writing programs, predicting outputs, and filling in code blanks related to concepts like loops, conditions, and data structures. The questions cover topics from basic syntax to more complex algorithms and problem-solving techniques.

Uploaded by

K I R A N
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Tutorial Sheet

The document is a question bank for programming and data structures, primarily focused on C programming challenges. It includes a variety of tasks such as writing programs, predicting outputs, and filling in code blanks related to concepts like loops, conditions, and data structures. The questions cover topics from basic syntax to more complex algorithms and problem-solving techniques.

Uploaded by

K I R A N
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Programming and Data Structures

Question Bank
Q.1 Write a program that prints Hello World without using a semicolon.

Q.2 What is the output of the following program and why?

#include<stdio.h>

void main(){

int n;

n=1,2,3;

printf(“%d”,n);

return 0;

Q.3 Write a program to swap two numbers using bitwise operators.

Q.4 Write a c program that takes a three digit number as input and checks whether it is an
armstrong number or not without using a loop.

Q.5 What is the output of the following program?


a) #include <stdio.h>

int main() {
char c = 127;
c++;
printf("%d\n", c);

return 0;
}

Q5 b)
#include <stdio.h>

int main() {
int x = 8;
int y = 6;

int res = x+++y;


printf("%d\n", res);

return 0;
}

Q.6 Write a C program that prints ‘%d’ and ‘\n’ on the console on two separate lines using a
single printf function.

Q.7 Write a program that takes a string as input and checks whether it is a palindrome or not. A
palindrome is a word, phrase, or sequence that reads the same backward as forward, ignoring
spaces and cases.

Q.8 a). #include <stdio.h>

int main() {
int x = 5, y;

y = (++x > 5) ? x++ : --x;

printf("%d %d\n", x, y);

return 0;
} What should be the output of this code and why?

b) #include <stdio.h>

int main() {

int x = 5, y, z;

y = (++x > 5) ? (z = x * 2) : (z = x / 2);

printf("%d %d %d\n", x, y, z);

return 0;

Q.9 Write a C program to determine eligibility for admission to a professional course based on
the following criteria:
Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=190
or
Total in Math and Physics >=140

Q.10 Write a program that computes the sum of the digits in the decimal representation of a
non-negative integer. For example, the sum of the digits of 320127 is 3 + 2 + 0 + 1 + 2 + 7 = 15.

Q.11 What will be the output of the program? Use x and y as the first and last two digits of your
roll number.
#include <stdio.h>

int main()
{
int x,y;
printf("Enter two numbers: ") ;
scanf("%d%d", &x, &y);
while(x!=y)
{
if(y>=x)
y-=x;
else
x-=y;
printf("x=%d ,y=%d\n",x,y);
}
printf("%d\n",x);
}
Q.12 Write a function named cosine which shall take a floating point variable x and evaluate the
Maclaurin series to the 5th decimal point of accuracy and print the value as a double data type.
Your program should compute each successive term based on the previously computed terms.

Q13. How many times will the print statement be executed?

for(i=0;i<=99;i++)
for(j=i;j<100;j++)
printf(“Tutorial 1\n”);

Q14. Fill in the blanks so that the following C program reads an integer and checks whether it is
a prime number or not.
int main()
{
int flag = 0;
int n,
scanf(“%d”, &n)
for (int i = _______; i <= __________; i++) {
if (_____ % ___ == 0) {
flag = 1;
_______;
}
}

if (flag == ____)
printf("The entered number is a Prime Number");
else
printf(" The entered number is not a Prime Number");
return 0;
}

Q15. Fill in the blanks so that the following C program reads the number of elements and prints
the fibonacci series.

#include<stdio.h>
int main()
{
int x=0, y=1,z ,i, n;
scanf("%d",&n);
printf("%d %d",x,y );//printing 0 and 1
for(i=_____;i<______;++i)
{
z=______+________;
printf(" %d",z);
_____=_____;
_____=_____;
}
return 0;
}

You might also like