Assignment for C Language Programming

1. WAP to print your name.

2. WAP that use \n and \t.

3. WAP to ADD the two numbers.

4. WAP to SUBTRACT the two numbers.

5. WAP to MULTIPLY the two numbers.

6. WAP to DIVIDE the two numbers.

7. WAP to find out the average marks of 5 students.

8. WAP to find out the Simple Interest.

9. WAP to area of a Circle.

10. WAP to do Conversions like : (i) Temperature Deg Celsius to Fahrenheit                                                                                                                                                                                                                                                       (ii) Length Meter to cm

11. WAP to reverse any 5 digit number

12. WAP to find the sum of all the digits of any 5 digit number

Topic: Conditional statements (if, if-else, else if, nested if)

1. WAP to find out the greatest in any 2 numbers

2. WAP to find out the smallest in any 2 numbers

3. WAP to find out the greatest in any 3 numbers

4. WAP to find out the smallest in any 3 numbers

5. WAP to find out whether the given number is EVEN or ODD

6. WAP to find out whether the given character is VOWEL or CONSONANT

7. WAP to find out whether the given character is CAPITAL or SMALL

Topic: Loops (for, while, do-while)

1. WAP to display counting form 0-10

2. WAP to display the Table of any number (e.g. 2 4 6 8 ……10)

3. WAP to display the Table if any number (e.g.

2*1=2

2*2=4

2*3=6 …….

2*10=20)

4. WAP to find out the factorial of any number.

5. WAP to display the Fibonacci series ( e.g. 1 1 2 3 5 8 13 23 ……..)

6. WAP to display following Patterns:

i)  1 1 1 1 1

2 2 2 2 2

3 3 3 3 3

4 4 4 4 4

5 5 5 5 5

ii) 1 2 3 4 5                                                                                                                                 1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

iii) 1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

iv) 1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

v) * * * * *

* * * * *

* * * * *

* * * * *

* * * * *

vi) (Vertically aligned left side)

*

* *

* * *

* * * *

* * * * *

vii) (Vertically aligned right side)

*

* *

* * *

* * * *

* * * * *

viii)(Vertically aligned from centre)

*

* *

* * *

* * * *

* * * * *

ix) (Reverse pattern of above -Viii)

* * * * *

* * * *

* * *

* *

*

x) (Vertically aligned from centre)

*

* *

* * *

* * * *

* * * * *

* * * *

* * *

* *

*

xi)

1 2 3 4 5 6 7 8 9

2 3 4 5 6 7 8 9

3 4 5 6 7 8 9

4 5 6 7 8 9

5 6 7 8 9

6 7 8 9

7 8 9

8 9

9

xii)

A A A A A

B B B B B

C C C C C

D D D D D

E E E E E

xiii) A B C D E

A B C D E

A B C D E

A B C D E

A B C D E

xiv)

A

B B

C C C

D D D D

E E E E E

xv)

A

A B

A B C

A B C D

A B C D E

Topic: Switch Case 

1. Write a menu driven program which has following options:

a. Factorial of a number.

b. Table of a number

c. Odd or even

d. Exit

2. Write a program which to find the grace marks for a student using switch. The user should enter the class obtained by the student and the number of subjects he has failed in.

− If the student gets first class and the number of subjects he failed in is greater than 3, then he does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the grace is of 5 marks per subject.

− If the student gets second class and the number of subjects he failed in is greater than 2, then he does not get any grace. If the number of subjects he failed in is less than or equal to 2 then the grace is of 4 marks per subject.

− If the student gets third class and the number of subjects he failed in is greater than 1, then he does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5 marks per subject

Topic Array:

1. WAP to print the 10 numbers stored in an array using loops.

2. WAP to enter or store any 10 numbers in a given array and find out the average using loops.

3. WAP to store 10 numbers in an array (ar1[ ]) and copy them to another array (ar2[ ]) and then print elements of ar2[ ].

4. WAP to store 10 numbers in an array and find out the largest number.

5. WAP to store 10 numbers in an array and find out the smallest number.

6. WAP to store 10 numbers in an array and find out the EVEN and ODD numbers.

7. WAP to search any numbers in an array and find out whether the number is in the array or not? if yes, then at what location in array..

8. WAP to store 10 numbers in an array ( ar1[ ] ) and copy them to another array (ar2[ ]) in reverse format (e.g. ar2[0] should be ar1[9] and ar2[1] should be ar1[8] …………… ar2[9] should be ar1[0] )and and then print ar2[ ]. i.e. Reverse the array (Using Loops).

Topic Functions: (Attempt following questions using simple functions and Call by value (with & without RETURN value)

1. Write a function to calculate the factorial value of any integer entered through the keyboard.

2. Write a function power ( a, b ), to calculate the value of a raised to b.

3. Any year is entered through the keyboard. Write a function to determine whether the year is a leap year or not.

4. Write a function which receives a float and an int from main( ), finds the product of these two and returns the product which is printed through main( ).

5. A 5-digit positive integer is entered through the keyboard, write a function to calculate sum of digits of the 5-digit number

6. Write a function to obtain the first 25 numbers of a Fibonacci sequence. In a Fibonacci sequence the sum of two successive terms gives the third term. Following are the first few terms of the Fibonacci sequence: 1 1 2 3 5 8 13 21 34 55 89…

7. Write a function to obtain the running sum of first 25 natural numbers

Topic Strings:

1. WAP that receives a string and count the number of vowels and consonants in the string.

2. WAP to Accept a String and display its alternate characters

3. WAP to Accept 2 strings and display the largest string

4. WAP to Accept a String and a Character and find out whether this character is present in the string. If Present then display how many times this Character occurs

5. WAP that receives a string and reverse it. (Without using standard string function).

Hint. Use pointers.