Tutorial Sheet
Tutorial Sheet
Question Bank
Q.1 Write a program that prints Hello World without using a semicolon.
#include<stdio.h>
void main(){
int n;
n=1,2,3;
printf(“%d”,n);
return 0;
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.
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;
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.
int main() {
int x = 5, y;
return 0;
} What should be the output of this code and why?
b) #include <stdio.h>
int main() {
int x = 5, 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.
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;
}