0% found this document useful (0 votes)
0 views

c_programs_exercise

The document outlines a series of programming tasks categorized into three levels: easy, intermediate, and difficult. Each level contains specific programming challenges, such as calculating the greatest common divisor, generating random numbers, and working with molecular configurations. The tasks cover various programming concepts and applications, including file handling, data structures, and mathematical computations.

Uploaded by

deepdt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

c_programs_exercise

The document outlines a series of programming tasks categorized into three levels: easy, intermediate, and difficult. Each level contains specific programming challenges, such as calculating the greatest common divisor, generating random numbers, and working with molecular configurations. The tasks cover various programming concepts and applications, including file handling, data structures, and mathematical computations.

Uploaded by

deepdt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Easy Programs

1) Write a program to print the greatest common divisor of two numbers.


2) Use function to print the factorial of any given number.
3) Write a program to create all the permutations of a given string.
4) Write a program to count the number of lines in a file.
5) Write a program to read the key board input and write it into a file.
6) Write a program to multiply two matrix of any given size.
7) Write a program to generate 100 random numbers and create their histogram.
8) Use structure to store the data of 10 students (name, age, height, mark)

Intermediate level

1) Write a program to read a pdb file and calculate the histogram of distances between each atom.
2) Write a program to calculate the area under the curve.
3) Write a program for matrix diagonalization.
4) Write a program that reads text from a file and reassembles the words in random order.
5) Write a program that takes the value of a long int and rotates the bit values so that the new value has bits set
from left to right rather than from right to the left. For example, if the original value is 01010011, the ouput
is 11001010.

Difficult Programs

1) Generate random 5000 points on the surface of a sphere of radius 10. The output should contain the
cartesian coordinates of all points. Plot it using Mathematica. Integrate it to calculate the volume.
2) Write a main program and a function. Generate random numbers between 1 and 1000 in the main program,
store in the array, pass the array to a function and calculate the histogram in the function, pass it to the main
program and print the value in the main program.
3) Print the decimal equivalent of the following number. Read the whole number and then work with it.
[100000000000000001111111111111111]. Use the proper convention for two’s complement. Print out the
corresponding positive number in binary. Also what is the output in a 64 bit system taking leading numbers
to zero.
4) Read your name (or any character) and produce random mutations of the characters without repetition to
produce the string of character. All characters must be present in the string.
5) Make a dictionary with arbitrary number of words. Program will ask an existing dictionary or a list of
words. If so, it will sort them first. Then it will aks if we would like to store any more words and take a few
inputs on screen by the user and finally store all the words sorted in a file.
6) Write a C program to select a particular word from the passage. The command should run from the terminal
and the output will be “YES or NO”. It also should print the number of times it appears. As an input, cut
and paste this question paper to create a text file. [./a.out student (ans: YES 3)]
7) Given some elements of a 10X10 matrix, fill the rest of the elements such that each row and column has
different single digit number between 1 and 9 (like Sudoku)
8) Generate 500 particles in box of dimension {10,10,10} randomly. Particles interact with each other with LJ
potential with Sigma=1.0 and Epsilon=1.0. Use Minimum Image convention to select new particles and
finally print the configuration in VMD using x,y,z format.
9) Given a string of arbitrary length, find out if it is a palindrome or not. Palindromes are symmetric, i.e., they
are same reading from both ends. [e.g., civic, dad, rotator are palindromes]
10) We know there are 10 possible dinucleotides and 136 possible unique tetranucleotides. How many unique
octanucleotides are there? Print all of their sequences
11) Generate two water type particles (triangular) with bonds 1.0 Å and angle 104.5 degree keeping the two
oxygens apart by 3.5. Rotate each of the molecules randomly using Euler angles. Calculate the probability
of formation of H-bond between them. Criterion for H-bond is when the angle between DonorHydrogen-
Acceptor is more than 150 degree.
12) Generate configuration of a ethane molecule where inputs are C-C bond lengths, C-H bond lengths, C-C-H,
H-C-H angle and H-C-C-H dihedrals. You can take standard bond lengths and angles.
13) Find the greatest common divisor (gcd) for n numbers. Program will first take an input of n followed by the
numbers and will produce the gcd.
14) Write a program to align two molecules. Take coordinates for a simple molecule, remove COM’s. Then
rotate one in all Euler angles and calculate RMSDs at each point. Print the configuration for the minimum
RMSD.

You might also like