FYBCS C Exercise_4

Set A . Apply all the three program development steps for the following examples. 

 1. Write a program to accept an integer n and display all even numbers upto n. 

 2. Accept two integers x and y and calculate the sum of all integers between x and y (both inclusive)

 3. Write a program to accept two integers x and n and compute x^n

 4. Write a program to accept an integer and check if it is prime or not. 

 5. Write a program to accept an integer and count the number of digits in the number. 

 6. Write a program to accept an integer and reverse the number. Example: Input: 546, Output 645.

 7. Write a program to accept a character, an integer n and display the next n characters.

Set B. Apply all the three program development steps for the following examples.

 1. Write a program to display the first n Fibonacci numbers. (1 1 2 3 5 ……) 

 2. Write a program to accept real number x and integer n and calculate the sum of first n terms of the series x+ 3x+5x+7x+… 

 3. Write a program to accept real number x and integer n and calculate the sum of first n terms of the series 1/x + 2/x^2  + 3/x^3 + …

 4. Write a program to accept characters till the user enters EOF and count number of alphabets and digits entered.

 5. Write a program, which accepts a number n and displays each digit in words. Example: 6702 Output = Six-Seven-Zero-Two. (Hint: Reverse the number and use a switch statement) 

Set C. Write C programs to solve the following problems  

 1. Write a program which accepts a number and checks if the number is a palindrome (Hint number = reverse of number) 
Example:Input    :3472 
Output : It is not a palindrome  number
Input    :262, 
Output : It is a palindrome  

Post a Comment

1 Comments