Solution to some of progrmming problems in C
-
Write a program to find the factorial value of any number entered through the keyboard.
-
Wap to check whether a given integer no. is palindrome or not.
-
Wap of find LCM and HCF of two numbers.
-
Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
-
Given the coordinates (x, y) of a center of a circle and it's radius,write a program which will determine whether a point lies inside the circle, on the circle or outside the circle. (Hint: Use sqrt( ) and pow( ) functions)
-
Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or at the origin, viz. (0, 0).
59.Write a program to find out how many days and how many weeks have passed between the dates. Also find out how many days could not get evened out into weeks.(e.g. days passes between 01/01/92 to 31/05/92)
-
Write a program for a matchstick game being played between the computer and a user. Your program should ensure that the computer always wins. Rules for the game are as follows:
- There are 21 matchsticks.
- The computer asks the player to pick 1, 2, 3, or 4 matchsticks.
- After the person picks, the computer does its picking.
- Whoever is forced to pick up the last matchstick loses the game.
-
Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.
-
Write a program to find the octal equivalent of the entered decimal number.
-
write a program to find the range of a set of numbers. Range is the difference between the smallest and biggest number in the list.
-
Write a program to print all prime numbers from 1 to 300. (Use nested loops, break and continue)
-
Write a program to fill the entire screen with a smiling face. The smiling face has an ASCII value 1.
-
Write a program to add first seven terms of the following series using a for loop:
1 2 3 a. - + - + - ...... 1! 2! 3!
b. 1,2, …….,n terms C. 1,3,5,7,…..n terms d. 2,4,6,8,…..n terms e. 1,2,4,7,11,……..n terms f. 0, 1, 1, 2, 3, 5, 8,…….n terms(Fibonacci series)
-
Write a program to generate all combinations of 1, 2 and 3 using for loop.
-
According to a study, the approximate level of intelligence of a person can be calculated using the following formula:
i = 2 + ( y + 0.5 x )
Write a program, which will produce a table of values of i, y and x, where y varies from 1 to 6, and, for each value of y, x varies from 5.5 to 12.5 in steps of 0.5.
-
According to the Gregorian calendar, it was Monday on the date 01/01/1900. If any year is input through the keyboard write a program to find out what is the day on 1st January of this year.
-
let the equation x + y = r represents a circle with centre at origin and radius r. Write a program that reads r from the keyboard and prints the number of points with integer coordinates that lie within the circle.
-
Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
-
Write a program to print all the ASCII values and their equivalent characters using a while loop. The ASCII values vary from 0 to 255.
-
Write a program to print all the ASCII values and their equivalent characters using a for loop. The ASCII values vary from 0 to 255.
-
Write a program that, for all positive integers i, j , k, and l from 1 through 1000, finds and prints all combinations of i, j , k, and I such that i + j + k = l and i < j < k < l.
-
Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour.
Write a program to produce the following pattaran where number of line entered by keyboard:(Q76-Q87) using for loop
**
**
** *
** *
1234 123 12 1
1234 567 89 0
i.e. if input is 7 * **
** * & if input is 8 * **
** *
i.e. if input is 7
**
** *
& if input is 8
**
** * 84. i.e. if input is 7
& if input is 8
12345 6789 012 34 5
i.e. if input is 5 1 234 56789 012 3
& if input is 6 1 234 56789 01234 567 8
0 10 010 1010
Write a program to produce the following pattaran,where number of line entered by keyboard:(Q88-Q97) using while loop
**
**
** *
** * 92.
i.e. if input is 7 * **
** * & if input is 8 * **
** *
**
** *
& if input is 8
**
** *
i.e. if input is 7
& if input is 8
12345 6789 012 34 5
i.e. if input is 5 1 234 56789 012 3
& if input is 6 1 234 56789 01234 567 8
0 10 010 1010
- Write a program to produce the following pattaran:
A B C D E F G F E D C B A A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A
99.Write a program to produce the following pattaran:
-
Write a program to fill the entire screen with diamond and heart alternatively. The ASCII value for heart is 3 and that of diamond is 4.
-
Write a program to print the multiplication table of the number entered by the user. The table should get displayed in the following form.
29 * 1 = 29 29 * 2 = 58 ...
- Write a program to produce the following output where number of line entered by keyboard:
1 2 3 4 5 6 7 8 9 10
- Write a program to produce the following output where number of line entered by keyboard:
1
1 1 1 2 1 1 3 3 1 1 4 6 4 1
- When interest compounds q times per year at an annual rate of r % for n years, the principle p compounds to an amount a as per the following formula
a = p( 1 + r / q )^^nq //where ^^ is power
Write a program to read 10 sets of p, r, n & q and calculate the corresponding as.
- Write a program to swap two numbers using bitwise operators.
106.Write a program to show bits of integer. ex. for input 2 output will be 0000000000000010 and for -1 1111111111111111.
107.The information about colors is to be stored in bits of a char variable called color. The bit number 0 to 6, each represent 7 colors of a rainbow, i.e. bit 0 represents violet, 1 represents indigo, and so on as given below. Write a program that asks the user to enter a number and based on this number it reports which colors in the rainbow does the number represents.
Red Orange Yellow Green Blue Indigo Violet
-
In an inter-college competition, various sports and games are played between different colleges like cricket, basketball, football, hockey, lawn tennis, table tennis, carom and chess. The information regarding the games won by a particular college is stored in bit numbers 0, 1, 2, 3, 4, 5, 6, 7 respectively of an integer variable called game. The college that wins in 5 or more than 5 games is awarded the Champion of Champions trophy. If a number is entered through the keyboard, then write a program to find out whether the college won the Champion of the Champions trophy or not.
-
The time field in the directory entry is 2 bytes long. Distribution of different bits which account for hours, minutes and seconds is given below. Write a program which would receive the two-byte time entry in form of number and print the hours, minutes and seconds. H H H H H M M M M M M S S S S S
-
Twenty-five numbers are entered from the keyboard into an array. The number to be searched is entered through the keyboard by the user. Write a program to find if the number to be searched is present in the array and if it is present, display the number of times it appears in the array.
-
Twenty-five numbers are entered from the keyboard into an array. Write a program to find out how many of them are positive, how many are negative, how many are even and how many odd.
-
Write a programm to implement binary search.
-
Write a programm to implement Selection Sort.
-
Write a programm to implement Bubble Sort.
-
Write a programm to implement Insertion sort.
-
Write a programm to implement mearging of two sorted array.
-
Implement the following procedure to generate prime numbers from 1 to 100 into a program.
step 1 Fill an array num[100] with numbers from 1 to 100 step 2 Starting with the second entry in the array, set all its multiples to zero. step 3 Proceed to the next non-zero element and set all its multiples to zero. step 4 Repeat step 3 till you have set up the multiples of all the non-zero elements to zero step 5 At the conclusion of step 4, all the non-zero entries left in the array would be prime numbers, so print out these numbers.
-
Write a program to copy the contents of one array into another in the reverse order.
-
If an array arr contains n elements, then write a program to check if arr[0] = arr[n-1], arr[1] = arr[n-2] and so on.
-
Find the smallest number in an array using pointers.
120.a.Write a program to show a function returning pointer.
120.b Write a program to show a function passing pointer.
-
Write a program to pick up the largest number from any 5 row by 5 column matrix.
-
Write a program to addition of two 3 x 3 matrix.
-
Write a program to multiplication of two 3 x 3 matrix.
-
Write a program to obtain transpose of a 4 x 4 matrix. The transpose of a matrix is obtained by exchanging the elements of each row with the elements of the corresponding column.
-
Write a program to sort all the elements of a 4 x 4 matrix.
-
The X and Y coordinates of 10 different points are entered through the keyboard. Write a program to find the distance of last point from the first point (sum of distance between consecutive points).
-
The first difference D1 of a sequence A of N elements is obtained by subtracting each element, except the last, from the next element in the array. The second difference D2 is defined as the first difference of Dl, and so on. For example, if
A: 1,2,4,7,11,16, 22, then D1: 1,2,3,4, 5, 6 D2: 1,1,1,1, 1 D3: 0,0,0, 0
Write a program that reads a sequence of 25 elements in an array and finds its first, second, and third differences.
-
A common problem in statistics is that of generating frequency distribution of the given data. Assuming that the data consists of 50 positive integers in the range 1 to 25, write a program that prints the number of times each integer occurs in the data.
-
A square matrix, that is, one having the same number of rows and columns, is called a diagonal matrix if its only non-zero elements are on the diagonal from upper left to lower right. It is called upper triangular, if all elements below the diagonal are zeroes, and lower triangular, if all elements above the diagonal are zeroes. Write a program that reads a matrix and determines if it is one of these three special matrices.
-
Write a program which finds four digit perfect squares where the number represented by the first two digits and the number represented by the last two digits are also perfect squares.
-
Write a program which finds a four digit number AABB which is a perfect square. A and B represent different digits.
-
If a number 972 is entered through the keyboard, your program should print "Nine Seven Two". Write the program such that it does this for any positive integer.
-
If a number 972 is entered through the keyboard, your program should print "Nine hundrad Seventy Two". Write the program such that it does this for any positive integer.
-
A positive integer is entered through the keyboard. Alongwith it the base of the numbering system in which you want to convert this number is entered. Write a program to display the number entered, the base, and the converted number. (Hint: Number conversion)
-
Write a programm to store marks of 10 students in array, find average.
-
Write a program to add or subtract 2 3*3 int array where choice is asked from user.
-
write a programm to multiply 2 3*3 matrics.
-
The Miniaturization Unlimited sells 5 types of memory chips through its retail outlets in 10 cities. The weekly sales of the company are stored i n a 5 x l 0 x 7 array SALES such that SALES( L, K, M ) denotes the sales of the L* memory chip in the K city on the M day of the week. Write a program that computes:
(a) The total weekly sale of each type of memory chip (b) The total weekly sale in each city and (c) The average daily sale of the company
-
Develop a program that receives the month and year from the keyboard as integers and prints the calendar in the following format.
September 2004 Mon Tue Wed Thu Fri Sat Sun 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Note that according to the Gregorian calendar 01/01/1900 was Monday. With this as the base the calendar should be generated.
-
Without using any string.h library functions Write a programm to Compares two strings without regard to case
-
Without using any string.h library functions Write a programm to finds first occurrence of a given character in a string.
-
Without using any string.h library functions Write a programm to finds last occurrence of a given character in a string.
-
Without using any string.h library functions Write a programm to finds first occurrence of a given sub string in another string
-
Without using any string.h library functions Write a programm to sets all characters of string to a given character
-
Without using any string.h library functions Write a programm to sets first n characters of a string to a given character.
-
Without using any string.h library functions Write a programm to reverses a string.
-
Write a program to count noumber of words in a string.
-
Without using any string.h library functions Write a programm to finds length of a string.
-
Without using any string.h library functions Write a programm to converts a string to lowercase.
-
Without using any string.h library functions Write a programm to converts a string to uppercase.
-
Without using any string.h library functions Write a programm to appends one string at the end of another
-
Without using any string.h library functions Write a programm to appends first n characters of a string at the end of another
-
Without using any string.h library functions Write a programm to copies a string into another
-
Without using any string.h library functions Write a programm to copies first n characters of one string into another
-
Without using any string.h library functions Write a programm to compares two strings charcter by charcter.
-
Without using any string.h library functions Write a programm to compares first n characters of two strings.
-
Write a program that extracts part of the given string from the specified position. For example, if the sting is "Working with strings is fun", then if from position 4, 4 characters are to be extracted then the program should return string as "king". Moreover, if the position from where the string is to be extracted is given and the number of characters to be extracted is 0 then the program should extract entire string from the specified position.
-
Write a program that converts a string like "124" to an integer 124.
-
Write a program that replaces two or more consecutive blanks in a string by a single blank. For example, if the input is Grim return to the planet of apes!! the output should be Grim return to the planet of apes!!
-
Write a program to sort a set of names stored in an array in alphabetical order.
-
Write a program to reverse the strings stored in the following array of pointers to strings:
char *s[ ] = { "To err is human...", "But to really mess things up...", "One needs to know C!!" } ;
-
Write a program to delete all vowels from a sentence. Assume that the sentence is not more than 80 characters long.
-
Write a program that takes a set of names of individuals and abbreviates the first, middle and other names except the last name by their first letter.
-
Write a program to count the number of occurrences of any two vowels in succession in a line of text. For example, in the sentence "Pleases read this application and give me gratuity' such occurrences are ea, ea, ui.
-
Write a program to encode the following string such that it gets converted into an unrecognizable form. Also write a decode function to get back the original string.
"Man's reach must always exceed his grasp.... or what is the heaven for?"
-
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the collage. (a) Write a function to print names of all students who joined in a particular year. (b) Write a function to print the data of a student whose roll number is given.
-
Create a structure to specify data of customers in a bank. The data to be stored is: Account number, Name, Balance in account. Assume maximum of 200 customers in the bank. (a) Write a function to print the Account number and name of each customer with balance below Rs. 100. (b) If a customer request for withdrawal or deposit, it is given in the form: Acct. no, amount, code (1 for deposit, 0 for withdrawal) Write a program to give a message, "The balance is insufficient for the specified withdrawal".
-
(c) An automobile company has serial number for engine parts starting from AA0 to FF9. The other characteristics of parts to be specified in a structure are: Year of manufacture, material and quantity manufactured. (a) Specify a structure to store information corresponding to a part. (b) Write a program to retrieve information on parts with serial numbers between BB1 and CC6.
-
A record contains name of cricketer, his 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 structure to hold records of 20 such cricketer and then write a program to read these records and arrange them in ascending order by average runs. Use the qusort( ) standard library function.
-
Write a menu driven program that depicts the working of a library. The menu options should be:
-
Add book information
-
Display book information
-
List all books of given author
-
List the title of specified book
-
List the count of books in the library
-
List the books in the order of accession number
-
Exit
Create a structure called library to hold accession number, title of the book, author name, price of the book, and flag indicating whether book is issued or not.
-
Write a program to show bits of float variable.(Union)
-
Write a program to show passing union To a function.
-
Write a program to show return union To a function.