Vous êtes sur la page 1sur 11

Getting Started (Program ZERO) WACP to print your name and address.

Mess the code around by mistyping main, leaving parentheses, moving around the position of main, changing flower braces with square brackets, using comma instead of semi-colon, typing print instead of printf and see all the errors that occur. Open a header file and see what is in a header file (stdio.h). Decision Statements 1. WACP to find if a number is positive, negative or zero. 2. WACP to determine if the triangle is valid or not and then calculate the area. 3. WACP to check a triangle is isosceles equilateral or scalene. 4. WACP to divide the larger number by the smaller number. The program code should consider all the possible cases of input values i.e. +ve, -ve, zeros. 5. Program to find top 3 tests average out of 5 tests conducted for a semester. 6. Program to determine that whether the character entered is upper case, lower case, digit or a special symbol. 7. WACP to find the third largest numbers out of six numbers input without using an array or loop. 8. Program to find grade of the student for four subjects marks for each subject to be entered by the user. Per>=85 grade=A Per<85 and per>=70 grade=B Per<70 and per>=55 grade=C Per<55 and per>=40 grade=D Per<40 grade=F 9. WACP to check a number is odd or even and +ve, -ve or zero. 10. WACP to check whether a year entered is a leap year. 11. Develop a calculator program which will use functions to add / subtract / divide /multiply 2 numbers. Division should check for zero. 12. WAP of finding greatest of 5 numbers given by the user. (With if...else if construct). 13. WACP to determine if a triangle is Equilateral, Isosceles, scalene or right angled triangle. 14. WACP to find the two smallest of five Numbers. 15. Evaluate using switch case. y( x, n) whose values are as below. 1+x n = 1.0 1+x/n n = 2.0 1+xn n = 3.0 1+nx n < 1 or n > 3 16. Punjab national bank is giving educational loans based on the following information. Students having distinction 0.5% discount in interest rates, first class students 0.25% , for all other students interest penalty of 0.25%. For parents serving in armed forces discount of 0.25% for each serving parent. For sports person a discount of 0.75%, for musician 0.5%. Students from rural areas 0.25% discount, for physically

challenged 0.5% discount, for single parents 0.5%. For applying one month in advance of the loan requirement 0.25% discount. Account holders of PNB 0.25% discount, for others 0.25% extra. Assuming the bank is charging 10% interest for educational loans, calculate the interest percent for an applicant. LOOPS 1. Program to perform the following operation. If the number is even divide it by two and if the number is odd multiply by 3 add 1 to it. Repeat the process and display the intermediate steps till the number becomes 1. 2. Program to print the following patterns-: a) ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A b) 1 01 101 0101 10101 * *** ***** ******* ***** *** *

c)

3. Program to find the sum of following series using functions (Read the value of parameters from the command line) a)1+(1+2)+(1+2+3)+(1+2+3+4)+..................+(1+2+3+.....n) b)1-1/3+1/5-1/7+1/9..............till the value of term is > 0.0000001 c)1+2/2!+3/3!+4/4!.................n/n! d)1-1/22+ 1/33-1/44+..............upto n terms. e)1+2*1+3*2+4*3+.................upto n terms f)1+2*1+3*2*1+4*3*2*1+.............upto n terms g)1-x+x2-x3+x4...........upto 15 terms

5. Write a menu driven program using functions to find? A. Factorial of a number B. Reverse of a number C. factors of a number 6. WAP of identifying whether the given number is prime or not 7. WAP of identifying how many prime numbers are there in-between 1 & N note: [This question should be done through for loop & while loop both] 8. WAP of creating Fibonacci series. Series should be - 0, 1, 1, 2, 3, 5, 8, 13, 21 9. Draw pyramids of * using loops [for, while] 10. WAP of calculating sum of squares of n numbers and print only those whose sum is odd 11. WAP of generating PASCALs triangle. Hint: Each number is the sum of the two numbers directly above it. 12. WAP of identifying all numbers between 1 to N as palindromes hint: 121 is palindrome [reverse is 121] 123 is not palindrome [reverse is 321] 13. WACP to print all the even numbers between 2 to N. Read the value of N from the command line. 14. WACP to print all the odd numbers between 1 to N. 15. WACP to calculate the Average of natural numbers between 1 to N. 16. WACP to print numbers divisible by 7 but not by 8 between 1 and N. Use #defines. 17. WACP to print numbers divisible by both 3 and 4 between 1 and N. 18. Accept four integers and print the 4-digit number formed by concatenating them. The result has to be in one single number (variable). 19. WAP of identifying the Armstrong number. 20. WAP to illustrate the sum of squares. 21. WAP of calculating grades of n students from 3 tests without using an array. 22. Accept the names and marks of 10 students in 6 subjects. Print the list. Also print the name of the first ranker, his/her percentage and his/her result and division. 23. WACP to read marks of four subjects as integers and print the average marks accurate to two decimal places 24. WACP to print from N to ZERO and then print Blast off. 25. WACP to print the pattern shown below. 0 1 2 3 N ... N N-1 N-2 .. 1 0 26. Read a number keep performing integer division till the number becomes less than zero. 27. WACP to print individual digits of a number from right to left. 28. WACP to perform sum of the following series a. 1, 4, 7, 10... N b. 2, 6, 10, 14,...N 29. WACP to perform sum of the series 1 -2 +3 -4 +5 -6...N 30. WACP to read three numbers and arrange them in ascending order.

31. WACP to read three numbers and arrange in descending order. 32. WAP to accept to accept a number from the user and test if it is a Fibonacci number or not. 33. Program to find all the prime numbers from 1 to 100. 34. Program to find all the Armstrong numbers from 1 to 1000. 35. Program to print the fibonacci series upto n terms. 36. Program to generate all the perfect squares from 100 to 1000. 37. Program to print a total of n asterisks. It should print 1 Asterisk at a time and after printing 5 Asterisk it should print the next five and so on. PROGRAMS ON ARRAYS 1. Program to sort the array of floats in ascending order. 2. Program to search a particular element in an array and print its position. 3. Program to find the frequency of each element in an array i.e. count of each element in the array. 4. WAP of reversing the array of numbers in the same array without using another array. 5. Program to insert the element-: a) At the beginning of an array b) At the end of an array. c) At a particular position in an array. For the above program the elements should be re-arranged without wasting any space. 6. Program to perform the delete operation in an array in following manner-: a) A particular element of an array to be deleted. (Read the element for deletion). b) An element at a particular position to be deleted. (Read the position at which deletion to occur) 7. Program to merge two arrays into sorted order provided that arrays to be entered in non-sorted order. 8. Write an program which will set the array element a[i] to 1 if i is prime, and to 0 if i is not prime. Assume the array size to be 10000. 9. Write a program to obtain the transpose of a 4*4 array. The transpose is obtained by exchanging the elements of each row with the elements of the corresponding column 10. Write a program which allow to perform any of the following operations on two 3*3 arrays 1) Add Arrays 2)Multiply Arrays 3)Subtract Arrays 11. Write a program to sort 3*3 array elements (row wise) without using a sorting algorithm. 12. WAP of adding two matrices using functions [passing array to functions] 13. WAP to trace the order of matrix from the user and print the matrix as per the order traced from the user.

14. WAP of storing 5 to 10 names in a double-dimension array and show the retrieval for use by printing them. 15. WAP to accept an array of numbers and sort the same using Bubble Sort Algorithm. 16. WAP to find the smallest value in an array of n elements using pointers. (Done after pointers) 17. Accept the names and marks of 10 students in 6 subjects. Print the list. Also print the name of the first ranker, his/her percentage and his/her result and division. 18. Program to perform following operation on matricesa) Find the column sum,row sum and diagonal sum of matrix. b) Print the upper triangle or lower triangle of a matrix. c) Find the transpose of a matrix. 19. WAP to find the symmetry of the matrix. hint: through transposing matrix. PROGRAMS ON FUNCTIONS 1. Program to find the sum of following series using functions-: a)1+(1+2)+(1+2+3)+(1+2+3+4)+..................+(1+2+3+.....n) b)1-1/3+1/5-1/7+1/9..............upto n terms. c)1+2/2!+3/3!+4/4!.................n/n! d)1-1/22+ 1/33-1/44+..............upto n terms. e)1+2*1+3*2+4*3+.................upto n terms f)1+2*1+3*2*1+4*3*2*1+.............upto n terms g)1-x+x2-x3+x4...........upto n terms 2. Write a menu driven program using functions to find? A Factorial of a number B Reverse of a number C factor of a number 3. Rewrite the temperature conversion program to use a function for conversion. 4. Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input a line at a time. 5 . Write the function htoi(s) , which converts a string of hexadecimal digits (including an optional 0x or 0X) into its equivalent integer value. The allowable digits are 0 through 9, a through f, and A through F . 6 .Write the function any(s1,s2) , which returns the first location in the string s1 where any character from the string s2 occurs, or -1 if s1 contains no characters from s2 . (The standard library function strpbrk does the same job but returns a pointer to the location.) 7. Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged. 8 .Write a function invert(x,p,n) that returns x with the n bits that begin at position p inverted (i.e., 1 changed into 0 and vice versa), leaving the others unchanged. 9 .Write a function rightrot(x,n) that returns the value of the integer x rotated to the right by n bit positions.

10 .Rewrite the function lower, which converts upper case letters to lower case, with a conditional expression instead of if-else . 11. Write a function escape(s,t) that converts characters like newline and tab into visible escape sequences like \n and \t as it copies the string t to s . Use a switch . Write a function for the other direction as well, converting escape sequences into the real characters. 12 .Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete listabc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. Arrange that a leading or trailing - is taken literally. 13 .Write the function itob(n,s,b) that converts the integer n into a base b character representation in the string s . In particular, itob(n,s,16) formats n as a hexadecimal integer in s . 14. Write a version of itoa that accepts three arguments instead of two. The third argument is a minimum field width; the converted number must be padded with blanks on the left if necessary to make it wide enough. 15 .Write the function strrindex(s,t) , which returns the position of the rightmost occurrence of t in s , or -1 if there is none. 16 .Write a routine ungets(s) that will push back an entire string onto the input. Should ungets know about bufand bufp , or should it just use ungetch ? 17. Write a program to find the nearest smaller prime number for a given integer; use a function to decide whether a number is prime or not. 18. Given a function with the following prototype int date_diff (int d1, int m1, int d2, int m2, int yr) Where d1 and m1 are the day and month of the first date and d2 & m2 are the day and month for second date and yr is the year to which both the dates belong. The function returns the difference between the two dates that fall in different year. Write a program to find the difference between two dates that do not fall in the same year. 19. Write a program to print whether the number entered is a prime/odd. Use functions. 20. Develop a calculator program which will use functions to add / subtract / divide / multiply 2 numbers. Code the functions as different source files and link them. (IMPORTANT PROGRAM) for understanding concepts. 21. Write a function, which checks whether one string is a sub-string of another string. 22. Write functions to insert and delete a string from an array of strings. Write a program that displays a menu to the user a) Insert String b) Delete Strings c) Exit Depending on the user choice the program will call functions that will insert / delete a string from an array of strings 24. Write a function for binary search. 25. WAP of calculating simple interest & compound interest using functions.

26. Create a header file and save all the functions in your header file and attached into your any C file and use the functions as per your desire in your C file. (create .c and .h files) 28. Write a function that takes a string and a number between 0 and 9 as parameters, display the string that many times, and returns its length. 29. Write a function to accept 10 characters and to display whether each input character is a digit, or a lower case alphabet or an upper case alphabet. 31. Write two functions using different approaches to swap two numbers without using a temporary variable. What type of parameters would you use? 32. WAP using functions to concatenate two strings, extract a substring from a string, and replace a substring in a string and to find the length of string. 33. Write a function to perform Linear Search. 34. WAP that consists of two files sum.c and maini.c. The file sum.c has a function that takes two integers arguments and stores the result in a global shared variable called sum. Accept the two inputs in maini.c, call the function sum.c and print the result in maini.c. 35. Write a function that accepts a string as argument and returns 1 if it is a palindrome and 0 if it is not. PROGRAMS ON RECURSION 1. Program to find the sum of first n natural numbers using recursion. 2. Program to find the gcd of two numbers using recursion 3. Program to find the sum of the digits of a number using recursion. 4. Program to print n terms of fibonnaci series using recursion. 5. Program to evaluate Ackerman (m,n) using recursion-: Ackerman (0,n) =n+1 for n>0 Ackerman (m,0) = Ackerman(m-1,1) for m>0 Ackerman (m,n)=Ackerman(m-1,Ackerman(m,n-1)) for (m,n)>0 6 .Adapt the ideas of printd to write a recursive version of itoa ; that is, convert an integer into a string by calling a recursive routine. 7 .Write a recursive version of the function reverse(s) , which reverses the string s in place. 8. Write a program to convert a number in decimal system to binary system. Hint: use recursion. 9. Write a recursive function to compute the factorial to a given number. Use the function to write a program which will generate a table of factorials of numbers ranging from 1 to m where m is the number entered by the user. POINTERS 1. WAP to find the smallest value in an array of n elements using pointers. 2. WAP for the following output: Addresses of variables val1 and val2:-

a : 2147483476 b : 2147483472 Addresses pointers ptr1 and ptr2 hold:ptr1 = 2147483476 ptr2 = 2147483472 values of val1, val2, val3 and val4 :val1 = 5 val2 = 10 val3 = 15 val4 = 14 values accessed by pointers ptr1 and ptr2 :*ptr1 = 5 *ptr2 = 10 3. WAP of illustrating the declaration and use of pointers to pointers. Hint: double pointers 4. WAP for illustrating void pointers. 5. Write a function that accepts character into a string by using a pointer. 6. Compute the length of the array using a pointer, given that the string is terminated by a null [\0] character. Finally print the string in reverse order using pointer. 7. Illustrate the main purpose of passing variables by pointers, with the help of a function which swaps two integers. PROGRAMS ON STRINGS 1. Program to perform following operations on strings. Make separate functions for each. a) Compare two strings. b) Reverse of a string. c) Concatenation of two strings. d) Check whether a string is palindrome or not. 2. Program to count the total number of vowels in a string. 3. Program to count total number of words, spaces and characters in a string. 4. Program to find a particular word in a string and print its occurrences in a string. 5. Write a function that takes a string and a number between 0 and 9 as parameters display the string that many times, and returns its length. 6. Write a function to accept 10 characters and to display whether each input character is a digit, or a lower case alphabet or an upper case alphabet. 7. Program to sort N names in alphabetical order using array of pointers. 8. Write a function, which checks whether one string is a sub-string of another string. 9. Write a program that accepts a sentence and returns the sentence with the entire extra spaces trimmed off. (In a sentence, words need to be separated by only one space; if any two words are separated by more than one space, remove extra spaces). 10. Write a program, which checks for duplicate string in an array of strings.

11. Program to delete all the vowels from the multi word string. 12. Program to take a name of an individual and abbreviates the first, middle except the last name. 13. Program to capitalize starting character of each word of a multi word string. 14. Write a program that will accept a string and character to search. The program will call a function, which will search for the occurrence position of the character in the string and return its position. Function should return 1 if the character is not found in the input string. 15. Write a function, which prints a given number in words. Ex: 125652 as One Lakh Twenty Five Thousand six hundred and fifty two. 16. Write a program to count the number of vowels in a given string. 17. Program to count the number of occurrences of any two vowels in succession in a line of text. eg:Please give me gratuity occurences are 2(ea,ui) 18. Program to use an array of pointers to strings str[].Receive two strings str1 and str2 and check if str1 is embedded in any of the strings in str[].If str1 is found then replace it with str2 . eg-: char *str[]={ We are the best, Move the world, Erase the past }; If str1 is world and str2 is car then the second string in str should get changed to Move the car. 19. Program to reverse all the strings stored in array of pointers to strings. eg-: char *str[]={ We are the best, Move the world, Erase the past }; 20. Write functions to insert and delete a string from an array of strings. Write a program that displays a menu to the user a) Insert String b) Delete Strings c) Exit Depending on the user choice the program will call functions that will insert / delete a string from an array of strings PROGRAMS ON STRUCTURES 1. Program to create a structure to specify data on students given below-: Roll number, Name, Department, Course, Year of joining Assume the college has 10 students a) Write a function to print all the students who have joined in a particular year. b) Write a function to print the data of a student whose roll number is given.

2. A record contains name of the cricketer, name, age, number of test matches that he has played and the average runs that he has scored in each test match. Create an array of structures to hold record of ten cricketers and then Write a program to read these records in ascending order by average runs. 3. Program that depicts the working of a library. The menu options of this menu driven program are: a) Add book information. b) Display book information. c) List the count of books in the library. d) List all books of a given author. 4. WAP to process student records by using structures. 5. WAP Class.c to ensure that the address field is itself a structure which contains the following fields: street, block, area, city and country Query: The search for the address should be conducted based on any of these fields 6. Create a database of a cricket team. The information should be categorized into: runs achieved, wickets taken, catches taken, catches dropped and run outs. Each player should be designated as either a batsman or a bowler. The captain, vice captain and wicket-keeper should have special status. Print the statistics of each player at the end of the season, giving all the information possible. Note: Here database means structure of structures. Creation of database is compulsory but to create the above program is optional, which can provide you the bonus internal marks. 7. Construct a program for managing the membership of a library. There are 2 kinds of members; those who can borrow a. 2 books at a time for 2 days b. 4 books at a time for 4 days WAP that accepts the name, code number and duration of the books borrowed and, displays the names and other information of all those members having dues. 8. WAP to store the data of students name, register number, and marks for 6 students. Display the data stored. Use a menu to enter the choice from the user to create a new data file or read the content of a previously created file. 9. WAP of illustrating self-referential structures. 10. WAP of illustrating dynamic memory allocation for string values using structures. 11. Using dynamic memory allocation reads names of 5 students from the command line and insert them into a linked list is ascending order PROGRAMS ON FILE HANDLING 1, Write a program to count number of words in a given text file. 2. WAP to copy the source file to another file. 3. WAP to implement the following data encryption technique. Add a positive integer to the original values of each of the character in the file. 4. WAP to change the alphabets in a file in the following manner. Replace each alphabet with the succeeding one i.e., A with B, B with C, ... Z with

A. 5. Program to read a file and convert its lowercase characters to upper case and its upper case characters to lower case. 6. Program to count the characters, spaces, tabs and newlines in a file. 7. Program to append the contents of one file at the end of another file. 8. Program to reverse each word of the given text file display the modified contents. 9. Program to search for a particular word in a file and replace it with a specified word. Make use of command line arguments as shown below: C>change <old word> <new word> <filename> 10. Program to create EMPLOYEE.DAT file containing employees information like empno, name, basic salary. Input data of ten employees. Read the file and display its contents. 11. Program to perform the following operations a) Search for a given empno b) Append a new record at the end c) Delete a given record You need to read a data file Employee.dat with the following record structure (empno,name,sal). 12. Program to create a data file stud.dat that stores the marks obtained in four different subjects by each student in a batch of 30 students . Then read this file, calculate the percentage of marks and store it in a new file results.dat along with the students name 13. Write a program to check print the highest scorer. Student details are stored in file in the format as below: StudNo 4 chars StudName 20 chars Marks 2 digits 14. WAP that accepts two filenames as command line parameters/arguments and appends the second file to the first. Note that in main, the first file is opened in the append mode, while the second one in read mode. 15. WAP to store the data of students name, register number, and marks for 6 students. Display the data stored. Use a menu to enter the choice from the user to create a new data file or read the content of a previously created file. 16. Create a file containing names of students with address, age and gender and insert them into a linked list in descending order by age. Define an appropriate structure to hold the data in the linked list.

Vous aimerez peut-être aussi