0% found this document useful (0 votes)
28 views12 pages

CP List of Programs

C Programming Practice

Uploaded by

Shreya Gokhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
28 views12 pages

CP List of Programs

C Programming Practice

Uploaded by

Shreya Gokhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 12
List of Programs and Algorithms PARTI ALGORITHMS Example 1: Write the algorithm for finding the sum of any two numbers. ; Example 2: Write the algorithm for determining the remainder of a division operation where the dividend and divisor are both integers. : : Example 3: Construct the algorithm for interchanging the numeric values of two variables. Example 4: Write an algorithm that compares two numbers and prints either the message identifying the greater number or the message stating that both numbers are equal. Example 5: Write an algorithm to check whether a number given by the user is odd or 7 even. Example 6: Print the largest number among three numbers. 7 Example 7: Take three sides of a triangle as input and check whether the triangle 8 can be drawn or not. If possible, classify the triangle as equilateral, isosceles, or scalene. Example 8: In an institution, grades have to be printed for students who appeared in 8 the final exam. The criteria for allocating the grades against the percentage of total marks obtained are as follows. Example 9: Construct an algorithm for incrementing the value of a variable that starts, 9 with an initial value of 1 and stops when the value becomes 5. Example 10: Write an algorithm for the addition of N given numbers. 9 Example 11: Develop the algorithm for finding the sum of the series 1+#2+3+4+..up 10 to N terms. Example 12: Write an algorithm for determining the sum of the series 2+4+8 +... 10 up to N terms, Example 13: ve an algorithm to find out whether a given number is a prime number 10 or not Example 14; Prepare a flowchart to read the marks of a student and classify them u into different am Write an algorithm for calculating the factorial of a given number N. 12 xample 16: Di : ipl aw a flowchart to find the roots of a quadratic equation. : R Example 17: W1 il pk rite an algorithm to print the Fibonacci series up to N terms. 13 Chapter 3 Expressing Algorithms 3 32 33 34 35 3.6 thmetic operation umber entered by the user, {function nal operator trate Sear vi cn or odd without using user Write a program Write a ea to demons a Write a program to find out fond the input m Write a program to find out w among three Write a program to find out greatest ag demonstrate bitwise operator. eee Enum datatype ; White « program to demonstrate “Fvutchar() function Write a program to demonstrate getchar() an Pa Write program to demonstrate gets() and puts() Write n to display message. Write» ea to demonstrate how to display number Write a program to display index value me Writes program to Boe distance in kilometer and convert it into meter, feet, centimeters, inches. Write a program to calculate simple interest. i ‘Write program to accept four digit number and display separate digit. Write « program to calculate gross salary where DA=50% of basic, TA=20% of basic and HRA=40% of basic salary. Accept basic salary from user. ‘Write a program to find out area of a circle, Write a program to find out area and Perimeter of a Rectangle. White a program to find out ASCII value of an entered number. A program to find the output A program to find the output Write a program to sWrite a program two numbers with the hel i f Ip of temp variable. White a program to sWrite a Program two numbers without using third verble ~ Iteration Write « program to print ASCH vale (A-2) using for loop, Write « c Program to accept the colour code for the colours of rainbow ‘and display its name. The The pro, sslong uur ada ‘gram should be Fepeatedly executed Write a program to print 1 vo to statements, Print 1 10 50 my Si umber usin ie {meen * tiny the word “@ foes vine imes ing for loop. Write a program to iso he ist Seven natural nS fie ti ie li St Seven nay He net loop. My i a ee 0 display the first n natural ry ve lere the Value of: n Y SLL 4eesseneaerrcarrce ess seyuses Rea B % oe 3.7 38 39 3.10 3. 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 3.20 oo Write a program to display to find the factorial of no. Write a program to display the multiplication of a uset The table must be up to 10. Write a program to display first n odd nos Write a program to calculate and display the sum of first n nat r entered no. Write a program to calculate and display the sum of the square of first n natural nos. Write a program to display first n elements of Fibonacci series. Write a program to calculate the value of the foll series: i 1 ltat—+— 4+ 2345 n Write a program to generate this series : 1 Upto n terms 23 455.6 Write a program to display “SPA” twice in a line and 3 such lines. Write a program to display the following SachinSachinBhavesh SachinSachinBhavesh SachinSachinBhavesh Write a program to display the following SPA SPASPA SPA SPASPA. Write a program to display the in triangle output 1 iW mM Ml M1 Write a program to display the following output eee peeeas Write a program to display the following output I 12 123 1234 12345 Write a program to display the following output 1 22 333 4444 55555 tural nos. List of Programs and Algorithms xv 1 78 78 79 80 80 81 82 82 83 84 84 85 85 3,22 3.23 3.24 a25 3.26 3.27 xvi List of Programs and. {gorithms Al t ygrams ygram to display the following outPY' pros Write a 1 12 123 1234 12345 Write a program to disp! I 23 456 910 inte program to display the following output A slay the following output AB ABC ABCD ABCDE i Write a program to display the following output BB ccc DDDD E EEEE Write a program to display the following output A BC DEF GHIJ KLMNO Ro @ program to display the following output oo ee fone sees N number of rows Write a pro; is i 7 Program to display the following Output | b} | 91 3 3.30 331 332 333 3.34 335 39 Write a program to display the following output 2 e see seeees eeneneee eeeaneee ener eee ” Write a program to display the following output Paes seees seaenes seeeennee seneees aes * Write a program to display the following output ABCDE ABCD ABC AB A Write a program to display the following output ABCDE FGHI JKL MN 0 Write a program to display the following output 54321 $432 343 54 5 Write a program to display the following output 1 121 12321 1234321 Write a program to display the following output A ABA ABCBA ABCDCBA 93 94 95 96 97 ae 1 entered no Arita agit of use soit List of Programs and ARS" rand produ of all the digi * find the su! red no. 36 | Write a program (0 fee deci i 3.36 using the while 107 of git it eo dj after the decimal point Waite a program 1 Our of iit De? i ‘ Write a program to find the er and store in another Variable, Ww ina floating Pine he gigit of USET ONT ary format. We 3.39 Write a program (0 ry decimal number We 340, Writea prsran te display following outP™t Ec 41 Write a progt i 5 + 5 f * ‘ be i it 3.42 Write a program to display following ou'Pu i 1 2 333 4444 55555 : 3.43. Write a program to display following output 1 2A 321AB 4321 ABC 3.44 Write a program to calculate the value of : x=1!+31+5!+.......2*m-I)! 3.45 Write a program to display following output. le 5 aniieneees 34 543 } $432 54321 3.46 Write a program to display the value of s for =1,5,10,15,20, +100 Mt sas, tvyttat? aes 3.47 Write a program to find the sine of an angle by adding all the terms in the sine series. The sine series is given by, xv sink eX-F tay to wpto n terms Chapter 4 Expressing Algorithms — Selection 4.1. Write a program to accept two floating a2 Write 4 program to check if the = ee of the input numbers. re @ Program to check if the user entered no ig gi we ® OY 7 OF NOt. 44 Write a program to check if the ete oe is divisible by 5 and 7 or not. 4.5 Write a program to accept two inte Prime no of not. Bers and print the largest amongst them, 414 415 4.16 417 418 Write a program to check whether the entered number by the user is positive or ive prea program to accept three integers and print the largest amongst them Write a program to display first n prime nos where the value of n is taken from the user ‘Write @ program to check if the entered no is Armstrong oF not. Write a program to display first n Armstrong nos where the value of n is taken from the user Write a program to check if the year entered is leap year or not White a program to display the factors of a user entered no. Write a program to display the class according to the marks scored by a student. The marks scored is taken as input and the class is displayed according to the following range Marks 85-100 | Merit 70-84 _| Distinction 60-69 _| First class {50-59 _| Second class 40-49 | Pass class 0-39 Fail Write a program to display the user entered single digit no in words. Write a program to display a user entered no in words. Write a menu driven program to perform add/subtrac/multiply/divide/modulus based on the user’s choice. Write a program to illustrate the switch statement for computing the area of different geometrical figures such as a circle, a square, a triangle, a rectangle etc. ‘The program should display the menu of figure codes of different figures. On choosing a particular figure code, the corresponding parameters required by that figure are accepted and processed. Finally, the area should be printed. Write a program using switch-case to display the class according to the marks scored by the student. The marks scored is taken as input and the class is displayed according to the following range: Marks [85-100 | Merit 70-84 | Distinction 0-09 50-59 | [40-49 O29 es @ program to display the month name by accepting the month no from the user. Write a program to find out GCD of entered number. 7 8 ng 120 121 122 122 3 125 126 127 129 132 135 thems Xxx List of Programs and Algorit a 421 4.22 4.23 4.24 4.25 TI Chapter 5 DECOMPOSITION OF SOLU SA 52 33 $4 as 5.6 5.7 58 59 5.10 Su rered ee Write a program to find out LCM ocd of entered nu! rit i M& Write a program to find out LCM A program to find the output find out re’ Write a program to fin 4 Write a program to check whether umber entered by the user. mntered num ie user is verses OF f : the entered ber by thi palindrome omot. ION fe function A program for function ber by using ’ A Program to calculate sum of three nul umber using function A program to find maximum among two 1 roger using recursion A program to calult the factorial of an ite a on A program to find the Fibonacci series ee Write a function to swap the contents of two its tion Write a program in ‘C’ to calculate Y = X" (Mal using recursion. Write a program to calculate the factorial of an integer st for five different sets Write a program in C to calculate and print Simple interes eae of value of Principal Amount, interest rate and Time perio« function interest and iterative control statement. ; Write paecian in C to perform the multiplication of TWO numbers using call by reference function cal. : Write a program using recursion to perform the summation of given Chapter 6 Arrays and Strings 6.1 6.2 63 64 65 6.6 67 68 69 6.10 6.11 6.12 6.14 Write a program to initialize a set of numbers in the arrays & display it in a standard output device. Write a program for sequential day calculation, Write a program to find average marks obtained by 25 students by accepting marks of each student, Write a program to read n numbers from the keyboard where n is defined by the Programmer to store it in one dimensional array and to display the content of that array. Write a program to calculate average marks of five Write a program to find largest element in array usin Write a program which reads two integer numbers multiplication and division using a separate functi Write a program to demonstrate 2D array. Write a program in C to read matrix of n Write a program to find out largest and smallest element Write a program to count a character that appears inst Write a program to convert all characters from lowers using library function, nnn Write a program in C using arra j to read . Print the largest and smallest number a i Nae fom user and then flay ee mu C using array to read the ara ; ie and print these numbers in ascending order from user and then subjects for 100 students, ing function, and finds their sum, difference, ‘on for each of these operations. in one-dimensional array. 8 for number of times. t0 uppercase without 16 169 10 im 191 19! 192 19 6.15 6.16 6.17 6.18 6.19 6.20 6.22 6.23 6.24 6.25 6.26 6.27 6.28 6.29 6.30 631 6.32 6.33 6.34 6.35 6.36 6.37 6.38 6.39 6.40 List of Programs and Algorithms xxi an array of has given 10 elements is argument to function. Write a program to find the smallest element in the first 4 characters of string of integer using function and passing this array 3 Write a program by using strncat() to concatenates “ ai 1”. here str] = “Best of “ and str2 ‘Luck to al wate py contents of str] to str2 where Write a program by using strepy() to COI i strl Semanal” cal steNew Delhi” before the execution of, aden Hi Write a program in C to sort the array using bubble sort. Given numbers 63, 34, 12, 32, 45, 76, 78, 54, 23, 39. Write a program to find the odd and even numbers from array. ; of given numbers in Write a program to arrange the element in an array 8 fnction ascending order using function and passing this array as argument to function. Given numbers are 54, 36, 83, 46, 94, 47, 58, 91, 11, and 44. Write a program to read 10 integer elements of an array to be called list [10] and print their sum. Write a program to shift 0 element to 1* element and 1" element takes place, of 2% element and so on; last element takes the place of 0" element. Write a program to find percentage and average marks of 5 subjects. Write a program to find prime numbers from 1 to 100. Write a program to read n x n matrix and print the sum of all lower diagonal (triangle) elements. Write a program for array addition. Write a program for array multiplication. Write a program to print the sum all the diagonal elements of matrix ‘A whose size is 5 x 5 and elements are entered from keyboard. Write a program to read elements of n x n matrix and print the sum of all elements of matrix. Write a program to read the contents of two arrays and merge the contents of both the array andarrange the final contents of array in descending order. Write a program to read a set of numbers from the keyboard and to sort out the given array of elements in ascending order using a function. Write a program to insert an element in an appropriate position in an array. Write a program to find the greatest & the smallest element in a given matrix. Write a program to check whether the matrix is unit matrix or not. Write a program to check whether a string is palindrome. Write a program to read a string and count the number of vowels in that string. Write a program to copy one string to another without using library function. Write a program to count number of words in given string. Write a program to read elements of a 3 x 3 matrix and compute square root of sum of the squaresof elements of the matrix, (i.e. the norm of the matrix). Write a program to calculate length of string without using string function, Chapter 7 Structures and Files mW 72 73 14 A program to print the initialized book informa i tion using struc i . Program to print the date using structure variable . — Program to accept book informatic i i Patan mation from user using structure variable & A program to print initialize structure member information for cricketer = 195 196 196 197 197 198 200 200 201 201 202 203 204 205 206 207 209 210 211 212 213 214 215 215 216 216 225 226 226 sal Ln ofPe ams and Algoritos + from user and display them for 4 1S 16 7 78 19 7.10 7 712 113 114 1S 7.16 717 118 79 721 12 123 124 128 126 727 7.28 129 730 731 732 1.33 134 138 7.36 137 739 7.40 ber ure mem alues of struct jing nested struc ‘A program to accept ¥ mmployee using ture, cricketer sialzed information fOr i nested structure and display AA program to print the ini employee Us . format A program to accent in! using array of structures thece 10 books by of structures ‘A program to print the information 60 student by Se dealt A program to print the aes to the See cant as function ‘A program to pass paper zed structure element 10 A program for passing init i function argument. arguments : to function as A program for passing iiializod stm as function Caney A program to pass structure t0 assing structure Var {A program using structure with a function by psd print using pointe structure, A program to accept information about os pointer to structie A program to print initialize information us! . Femployee using pointer os ; A program to print the initialized information ook & display the petites A program to declare pointer to structure of type soe ome information of employee using pointer to structure & displ them. A ea to accept employee information using pointer to array structure & display them. : nia for printing student rollno, name and address of student by using union A program for printing student rollno, name, and branch of student by using typedef A program to open file in reading mode, A program to close the file, A program to store the entered string in to file by using pute() and getchar(); A program to read the stored string from file by using gete() and display usin; iB Putchar(); A program to read strings from the file using fgets() and dig AA program from writing string plays them on the screen into a file using fputs() by using fwrte() A Program to acept he book information asing fwrite() from user and store in the file by a reat 10 Tead cricketer information from the file by Using fread) and display A Program to read the ile and ye ‘Seek() and read the text after ski ‘ripen et Bea tagy using fell), ‘er from text file seek() along with their Position in file Stes See Skee R = 258 2 2) 29) mat wf , i 741 742 143 7.44 745 746 147 748 749 7.50 751 7.52 7.53 7.54 155 7.56 CUCU a ——_— xxiii List of Programs and Algorithms ‘A program show the use of rewind() function ‘A program to check whether end of file is reached, A program to check whether EOF is reached. Write a program to copy a file into another using fpute( ) and fgetet ). Write a program in C to read data from the keyboard, write it in a file called INN, again read the same data from the file and display it on the screen, i Write a program in C to write 50 different numbers in the file called NUMBERS using putw( ) then read the same file using getw( ) to write all odd numbers to a file called ODD and all even numbers to a file called EVEN: Write typedet and struct declaration for student in college. Write typedef and struct declaration for customers in a bank. ’ Write a program class to ensure that the address field is itself a structure which contains the following fields: street, block, area, city, country. The search for the address should be conducted based on any one of these fields. js Write a program to print the current position of the file pointer and size of file using ftell( ) function, Write a program to open file text.dat and write data in to that file. Write a program to accept values of structure member from user and display them for 14 cricketer. Write a program to enter data of 50 students with their name, class, sex, rollno, height & weight Write a program to create backup of the text.bat file Write a program to accept student information and store in the file using fwrite() Write a program to count chars, spaces, tabs, new lines ina file Chapter 8 Pointers 81 8.2 83 84 85 8.6 87 88 89 8.10 8.11 ‘A program to print the address of variable using ‘&’ address of operator along with its value ‘A program to print the value of variable through pointer variable ‘A program to print address and values of a variable ‘A program to print address and values of a variable ‘A program to print address and values of a variable A program to display the address of pointer variable before and after increment A program to display the address of pointer variable before and after decrement A program to demonstrates the use of pointer arithmetic operators with pointer A program to display the difference in address & their values ‘A program to interchange two numbers by call be value A program to interchange two numbers by call be reference A program for returning more than one values from a function through arguments A program to calculate and print gross salary employee, using call by reference A program to calculate factorial by using call by reference A program for pointer to function A program for invoking function using pointers A program accept two numbers and find greatest number by using pointer function A program to access array elements using pointers A program to print value of variable with address A program to finds the value of the I using function tgest element in an integer array by 265 266 267 269 270 270 211 211 272 273 214 274 275 275 276 277 281 282 282 283 283 284 284 285 285 287 288 288 289 289 291 xxiv List of Programs 8.26 8.27 8.28 8.29 8.30 831 8.32 8.33 8.34 8.35 8.36 8.38 8.39 8.40 8.41 8.42 8.43 8.44 8.45 to a function elements by passing array A program to display array proach ‘an array using array name itself A program to find sum of al ps pointer ith their addresses using array name A program display aay elements with inter iy 3 Apo to access array elements ane Laeger of cocond array into anot A program to copy one array int should be opposite to first array i iter vartobls int element of array using Pol ee f Tot of sean piven in the program; write a program to exchange the position of the names "Sachin"and "Saurav" A program to demonstrate pointers and character arrays A program the print two strings assigned to pointer eat A program print the content of character array by using poi A program for array of pointers ' = A program to demonstrate the use of, Pointer to pointer ; i A program to find length of a given string including and excluding white Spaces Write a C program to initialize a string as “Engineering” and Print it in Teverse order using pointers, Write a program to find length of a String using pointer method Write aC Program to sort an array of 10 integer elements in descending order using pointers, Write a C program to initialize in reverse order using pointers, Write a program to copy the Contents one int array to another int array using pointers, Write a program to Teverse characters of string using pointer. Write a Program in C to concatenate following two st a string as “I am Proud to be Indian” and print it N ‘currence of given: abe [ ] = it - iow Ee Write @ program to Copy the contents of one String to anot! strings using Pointer, Write a program for comparing tw Write a program for Write a program to ¢ ‘Wo pointer Strings usin, si Copying pointer Strings using strepy( ‘oncatenate two, Strings using Pointers, 303 30 30 308 303 310 3 312 312 313 314 34

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy