[Link].
1
To Find Factorial of a given number
Date:
Aim:
This task is to find factorial of n numbers. The factorial of a non-negative integer n, denoted
by n!, is the product of all positive integers less than or equal to n. For example, the value of 0! is
1, according to the convention for an empty product.
Definition:
The factorial of a non-negative integer n, denoted by n!, is the product of all
positive integers less than or equal to n.
n!=nx(n-1)x(n-2)x(n-3)x…3x2x1
For example, 5! = 5*4*3*2*1=120
TASK:
1. To find the factorial of n numbers.
2. Identifiy the number of variables to be used.
3. Identify the data type of each variable.
INPUT FORMAT:
Input consists of a single integer n, where 1<=n<=100.
OUTPUT FORMAT:
Print the factorial of n.
SPACE FOR PROGRAM & FLOW CHART
OUPUT
SAMPLE INPUT: 3 4 5 6
SAMPLE OUTPUT: 6 24 120 720
Result:
[Link].2
To Find Fibonacci series of a given number
Date:
Aim:
To write a C program to generate the Fibonacci Series
The Fibonacci sequence begins with 0 and 1. These are the first and second terms, respectively.
After this, every element is the sum of the preceding elements:
Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2)
Task
Start counting from Fibonacci (1) =0. This might differ from some other notations that
treats Fibonacci (0) =0.
The overall equation is:
= 0, n = 1
Fibonacci(n) = 1 , n = 2
Fibonacci(n-1) + Fibonacci(n-2) , n > 2
Input Format
One line of input, the integer N.
Constraints
0<N<=40
Output Format
Output one integer, the Nth Fibonacci number.
Function Prototype
The code for accepting the input and displaying the output is provided. You will be provided the
input parameter N, and you need to return the Fibonacci Nth term.
Sample Input and Output Values for the Fibonacci Series
fibonacci(3) = (0+1) = 1
fibonacci(4) = (1+1) = 2
fibonacci(5) = (1+2) = 3
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
3
4
Sample Output
The Fibonacci series for 3 is: 0,1,1
The Fibonacci series for 4 is: 0,1,1,2
Result:
[Link].3
To Find given number is Prime or Not
Date:
Aim:
Write a C Program to Find a given number is prime or Not
Input Format
First line of input consists of T , number of test cases.
For each test case, input consists of a number n .
Constraints
T <= 1000
2 <= n <= 1000000
Output Format
For each test case print Yes if the number is prime or No if the number is not prime.
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
3
2
4
5
Sample Output
Yes
No
Yes
Result:
[Link].4
To Find sum of even numbers
Date:
Aim:
To Write a C Program to Find the Sum of Even Numbers in a set of numbers in an Array
Given an array of N integers,
Input Format
The first line contains an integer, N, denoting the size of the array.
The second line contains N space-separated integers representing the array's elements.
Output Format
Print the sum of the array's even numbers as a single integer.
Explanation
Let A =[1,2,3,4,5,6,7,8,9,10]
We print the sum of the array's even number, which is: 2+4+6+8+10=30
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
6
2 4 6 8 10 12
Sample Output
42
Result:
[Link].5
To Check given String is Palindrome or not
Date:
Aim:
This task is to check given string is palindrome or not.
Palindrome is a number, word, phrase, or sequence that reads the same backward as forward,
e.g., "madam" or "malayalam" or 1221 or 10301.
TASK:
1. To print the given string is palindrome or not palindrome.
2. Use various string handling functions.
INPUT FORMAT:
Input consists of a sequence of characters n, where 1<=n<=100.
OUTPUT FORMAT:
Print the string is palindrome or not palindrome
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
SAMPLE INPUT: MADAM, MALAYALAM
SAMPLE OUTPUT: Palindrome , Not Palindrome
Result:
[Link].6
To check the given number is Armstrong or Not using functions
Date:
Aim:
Write a C Program to check the given number is Armstrong or not using functions.
Definition:
Those numbers which sum of its digits to power of number of its digits is equal to that
number are known as armstrong numbers.
Example 1: 153
Total digits in 153 is 3
And 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
Input Format
First line of input consists of T , number of test cases.
For each test case, input consists of a number n .
Constraints
T <= 1000
1 <= n <= 1000000
Output Format
For each test case print Yes if the number is Armstrong or No if the number is not armstrong.
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
0
1
122
370
371
Sample Output
Yes
Yes
No
Yes
Yes
Result:
[Link].7
To Count the number of Vowels from the given String
Date:
Aim:
Write a C Program to count the number of vowels from the given string using switch case.
Definition:
A letter representing a vowel sound, such as a, e, i, o, u.
Task:
Traverse entire string character by character and increment the vowel counter if the
current character is vowel.
Example 1: Karpagam University
The vowels in the input is a,a,a,U,i,e,i.
Total Vowels = 7
Input Format
First line of input consists of T , number of test cases.
For each test case, input consists of a characters n .
Constraints
T <= 1000
1 <= n <= 1000000
Output Format
For each test case print the total number of vowels.
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
Computer Science
C Programming
Welcome to Coimbatore
Sample Output
Total Vowels = 6
Total Vowels = 3
Total Vowels = 9
Result:
[Link].8 To read a line of text from keyboard and print the number of characters, words
Date: and spaces
Aim:
Write a C Program to read a line of text from keyboard and print the number of
characters, words and spaces.
Task :
The program takes string input from the user and stores in variable line.
Initially, the variables characters, words and spaces are initialized to 0.
When the character is found, character variable is incremented by 1.
Similarly, words and spaces are incremented when these characters are found.
Finally, the count is displayed on the screen.
Example 1: Karpagam University
Characters = 18
Words = 2
Spaces= 2
Input Format
For each test case, input consists of a characters n.
Constraints
a <= n <= z
Output Format
For each test case print the total number of characters, words and spaces.
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
Computer Science
C Programming
Welcome to Coimbatore
Sample Output
Characters = 15 Words =2 White Spaces = 2
Characters = 12 Words =2 White Spaces = 2
Characters = 19 Words =3 White Spaces = 3
Result:
[Link].9
To print student record using structure
Date:
Aim:
Write a C Program to print student record using structure.
Task :
a structure, student need to be created.
This structure has three members: name (string), roll (integer) and marks(float).
Then, we created a structure array of size 10 to store information of 10 students.
Using for loop, the program takes the information of 10 students from the user and displays it on
the screen.
Input Format
For each test case T, input consists student name, roll no and marks.
Constraints
name: a-z
1>=Roll no<=10000
1>=marks<=10000
Output Format
For each test case print the student name, roll no and marks.
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
Enter information:
Enter Name : Arun
Enter Rollno: 001
Enter Marks : 34.5
Sample Output
Displaying Information:
Name : Arun
Rollno: 001
Marks : 34.5
Result:
[Link].10
To find factorial of a number using recursion function
Date:
Aim:
To Write a C Program to find factorial of a number using recursion function.
Given an array of N integers,
Input Format
The first line contains an integer, N.
Output Format
Print the factorial of the numbers using recursive function.
Explanation
Print the factorial of integers, which is: 5!=5*4*3*2*1=120
SPACE FOR PROGRAM & FLOW CHART
OUTPUT
Sample Input
5
6
Sample Output
120
720
Result: