Professional Documents
Culture Documents
KIIT University, Bhubaneswar (Looping: while, do..while, for), break, continue, goto
3.11 What will be the output of the following C (except for the order). These are called prime
program? Justify. factors of a number. In other words, In
int main () number theory, the prime factors of a positive
{ integer are the prime numbers that divide that
int i=0, x=0; integer exactly, without leaving a remainder.
for (i=1 ; i<10; i * =2) The process of finding these numbers is called
{ x++; integer factorization, or prime factorization.
printf ("%d", x); - Enter a number : 100
} - The prime factors of 100 are 2(2) and 5(2)
printf ("n x=%d", x); , that is, 100 = 2 x 2 x 5 x 5, and those
} numbers are primes.)
3.22 WAP to find the first n numbers of a
3.12 Write the output of the following code. Fibonacci sequence.
void main() { 3.23 WAP to evaluate the equation y=xn where n is
int i; a non-negative integer.
for(i=0; i<=2; i++);{ 3.24 WAP to print the series as 1 2 7 15 31
printf("%d",i); ..........n, where n is given by user.
printf("Bhubaneswar"); } 3.25 WAP to print the series as 1 1 2 3 5 8 13
printf("India"); } ..........n, where n is given by user.
3.26 WAP to print the series as 3 5 7 11 13
Looping (LONG TYPE) 17..........n, where n is given by user.
3.27 Write a C program to evaluate the following
WAP stands for Write a program series
1+ 1/2!+2/3!+3/4!+⋯+n/((n+1)!)… where
3.13 WAP to calculate the factorial of a given n is a user input.
number. 3.28 WAP to print all odd and even numbers
3.14 WAP to calculate the sum of digits of a given separately within a given range. The range is
number. input through user.
3.15 WAP to display the reverse of a number 3.29 WAP to calculate sum of squares of first n
entered through keyboard. odd numbers.
3.16 WAP to find the GCD/HCF of two numbers . 3.30 WAP to convert a decimal number into its
3.17 WAP to check whether a number n is prime equivalent binary number.
number or not. 3.31 WAP to convert a binary number into its
3.18 WAP to check whether an input integer is equivalent decimal number.
perfect number or not. 3.32 WAP to print the following pattern for n rows.
3.19 WAP to check whether an integer number is a Ex. for n=5 rows
Armstrong number or not!. A
3.20 WAP to check whether an input integer is A B
strong number or not. A B C
(Hint: If the sum of factorials of all digits of a A B C D
number are equal to the number are equal to A B C D E
the number, it is called a strong number )
3.21 WAP to find out the prime factors of a
number entered through keyboard (distinct).
(Hints: A prime number is any number with
no divisors other than itself and 1, such as 2
and 5. Any number can be written as a
product of prime numbers in a unique way