MAP

C - PRACTICAL EXAMPLES & ASSIGNMENT - 1


Printf () Statement
1.     Print "Hello"
2.     Print Your Name On screen.
3.     Print Address on screen.

Scanf() statement
4.     Enter the value of an integer variable and print it on screen.
5.     Print value of I and check i is less, equal or greater than zero.
6.     Input two numbers and prints its square and cube.
7.     Input two numbers and prints its Addition, Subtraction, Multiplication, and Division.
8.     Verify the formula l=(c+d)*(g+h).
9.     Verify the formula x=((k-4)*(a*4))/100
10.  Verify the formula s=((4*a+c)-2*a*b)/100
11.  Verify the formula a=p*(1+(r/100)/n)-p
12.  Verify the formula t=((v+s)+(l-m)*l)
13.  Calculate the area of circle.
14.  Calculate the area of Triangle.
15.  Verify the formula c=(a+b)*(a+b)
16.  Write a program to count the simple interest.
17.  Input a Rupees and prints its value converted into Dollar.
18.  Input a Number of Chairs and its Total Cost and Prints the Cost of Each chair.

If...Else statement
19.  Enter value and check it is less, equal or greater than zero.
20.  Input 2 number and print the maximum among them.
21.  Input 2 number and print the maximum among them. (with conditional operator)
22.  Input 2 number and print the minimum among them.
23.  Input 2 number and print the minimum among them. (with conditional operator)
24.  Input 3 number and print the maximum among them.
25.  Input 3 number and print the maximum among them. (with conditional operator)
26.      Write a program that find minimum and maximum out of 3 values.
27.      Write a program that interchange or swap the values of 2 variables.
28.      Write a program to interchange the value of 2 variable without using 3rd variable
29.      Write a program to check whether the entered no is odd or even.
30.  Get a character in lower case form user and display it in upper case.
31.  Get a character from user and print tell that is it vowel or consonant.   
32.  Print & calculate area of circle, area of triangle & (f+g)*(f+g) & simple interest & exit in one program.
33.  Print & calculate addition, substrection, multiplication & division of two value in one progarm using if() statement.
34.      Write a program that take input of 5 subjects marks. Count the percentage. Print the result  for following condition
If  student has 70% or more then 70% then DISTINCTION.
If  student has percentage between 60 and 69 then FIRST CLASS.
If  student has percentage between 50 and 59 then SECOND CLASS.
If  student has percentage between 40 and 49 then PASS CLASS.
If  student has percentage less then 40  then FAIL.
35.      Write a program that take input of 5 subjects marks. If student get 40 or more then 40 then  he is PASS in that subject  otherwise FAIL print the result for following condition.
If student is pass in all  subjects  then declare PASS.
Is student is fail in 1 or 2 subject then declare ATKT.
If student is fail in more then 2 subject then declare FAIL.
36.      Write a program that count the area for circle, square, rectangle and triangle using Switch-Case control structure
37.      Write a  program that take input of year in 4 digit. Determine whether the year is leap year or not.(try to solve this problem with && and or operator)
38.      Write a program that determine the grade of steel according to following condition.
1   Hardness must be greater then 50
2   Carbon must be less then 0.7
3   Tensile must be greater then  5500
Take the input for above qualities through keyboard from user Grades are decided as follows.
Grade A if all 3 conditions are met.
Grade B if  condition (1) and (2)  are met.
Grade C if  condition (2) and (3)  are met.
Grade D if  condition (1) and (3)  are met.
Grade E if only one condition met.
Grade F if none of conditions are met.
39.      Write a program to find maximum from 3 values using conditional operator.
40.      Write a program that generate same output as of program no (10) using break statement.
41.      Write a program that performs the sum of given numbers until user says no using Go-To statement.
42.      Write a sample program that demonstrate the use of Continue statement.
Looping structure (while, do...while, for)
43.  Print 1 to 10.
44.  Print 2,4,6,8,10,
45.  Print 1,3,5,7,9,
46.  Print 1,2,4,8,16,32,64,
47.  Print 10 to 1
48.  Print 1,10,2,9,3,8,4,7,5,6,
49.  Print 2,11,20,28,25,41,46,50,53,55,56,
50.  Print first 100 even numbers.
51.  Print first 100 odd numbers.
52.  Print first 50 natural numbers.
53.  Print the total of 1 to 50.
54.  Print the total of 1/2+2/3+....+9/10.
55.  Print the total of 1-2+3-4+5-6+7-8+9-10.
56.  Print the total of first 100 even numbers.
57.  Print the total of first 100 odd numbers.
58.  0.1+0.02+0.003+0.0004+0.000005.
59.  Except one no from user and display Reverse of it.
60.  Except one no from user and display sum of its digits.
61.  Except one no from user and display its factorial.
62.  Except one no from user and find if it is prime or not.
63.  Except one no from user and find if it is Armstrong or not.
64.  Print 0 1 1 2 3 5 8 13 21 34 55 … (Fibonanci series)
65.      Generate the value of n! factorial for n number
66.      1+2+3+4+5+6 up to  n terms
67.      1+3+5+7+9 up to n terms
68.      1+2+4+5+7+8 up to n terms
69.      Write a program that perform the following output for n by n matrix without using array
1   2    3   4   5
10   9    8   7  6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
70.      X+ X2 + X3 + X4 + X5  up to n terms
71.      X/Y +  X2/Y2 + X3/Y3  up to n terms
72.      X/Y +  X2/Y + X2/Y2 +  X3/Y2 +  X3/Y3  up to n terms
73.      A+AR+AR2+AR3+AR4 up to n terms
74.      1! + 2! + 3! + 4! + 5! Up to n terms
75.      1! + 3! + 5! + 7! Up to n terms
76.      X + X3 + X5 + X7 up to n terms
77.      X/1 + X2/22 + X3/33 + X4/44  up to n terms
78.      AB+CD+A2B2+C2D2 up to n terms
79.      Write a program to generate fibona series  0,1,1,2,3,5,8,13 up to n terms.
80.      1*3 + (1+2) * 32  + (1+2+3)  * 33 + (1+2+3+4) 34 up to n terms
81.      1!/2!  + 3!/4! + 5!/6!   Up  to n terms
82.      X/1!  -   X3/3!  +  X5/5!  - X7/7! Up to n terms
83.      Write a program to calculate the sum of odd and even number between given no of series.

(Perform all the exercises from 62 to 73 in following 3 patterns)
Pattern-I
Pattern-II
Pattern-III
*
**
***
****
*****
*
**
***
****
*****
*
**
***
****
*****

Nested looping structure.

84.  Print pattern like follow.
12345
12345
12345
12345
12345
85.  Print pattern like follow.
11111
22222
33333
44444
55555
86.  Print pattern like follow.
1  2  3   4   5
2  4  6   8   10
3  6  9   12 15
4  8  12 16  20
5  1015  20 25
87.  Print pattern like follow.
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

88.  Print pattern like follow.
1
22
333
44444
555555
89.  Print pattern like follow.
1
12
123
1234
12345
90.  Print pattern like follow.
5
54
543
5432
54321
91.  Print pattern like follow.
1
21
321
4321
54321
92.  Print pattern like follow.
1
2  3
4  5  6
7  8  9  10
1112131415


93.  Print pattern like follow.
1
10
100
1000
10000
94.  Print pattern like follow.
1
01
010
1010
10101
95.  Print pattern like follow.
1
10
101
1010
10101
96.  Print pattern like follow.
a
bb
ccc
dddd
eeeee
97.  Print pattern like follow.
a
b c
d e f
g h i j
k l m n o
98.  Print pattern like follow.
z
y  x
w v u
t   s  r q
p  o n m l
99.  Print pattern like follow.
5
45
345
2345
12345
100.                Print pattern like follow.
12345
1234
123
12
1
101.                Print pattern like follow.
12345
2468
369
48
5
102.                Print pattern like follow.
54321
5432
543
54
5
103.                Print pattern like follow.
54321
4321
321
21
1
104.                Print pattern like follow.
12345
2345
345
45
5
105.                Print pattern like follow.
55555
4444
333
22
1
106.                Print pattern like follow.
2 4 6 8 10
4 6 8 10
6 8 10
8 10
10
107.                Print pattern like follow.
a b c d e
b c d e
c d e
d e
e
108.    Write a program that perform the following output for n rows
1
3  
5  6
8  9 10
109.    Write a program that perform the following output for n  rows
*
*
* *                 
* * *
110.    Write a program that perform the following output for n  rows
      1
         1          2
      1       2         3
1        2         3         4
111.    Write a program to perform the following output for n rows
      1
   1 0 1
1 0 1 0 1
112.    Write a program to perform the following output for n rows
1 *
2 *  *  *
3 *  *  *  * *
4 *  *  *  *  *  * *
113.    Write a program that perform the following output for n rows
1 2 3 4 5 4 3 2 1
1 2 3 4    4 3 2 1
1 2 3          3 2 1
1 2                2 1
1                             1
114.    Write a program for following output for n no of rows( Pascal triangle)
                                             1
                                 1                      1
            1                      2                      1
1                      3                      3                      1
1                   4                      6                      4                      1

Array & Pointer
115.                Accept 5 numbers in an array and display it.
116.                Accept 10 numbers in an array, sort it and display it.
117.                Accept 4 numbers in 2-d array.
118.                Accept 9 numbers in form of matrix. (3 X 3 matrix)
119.                Accept 10 numbers in an array and store it in another array.
120.                Accept 10 numbers in an array and find total of positive and negative no.
121.                Accept 5 numbers in an array and find maximum and minimum value.
122.                Accept 5 numbers in an array and calculate average of it.
123.                Accept values in 3 X 4 array and find out row total, column total, maximum, minimum and total. 
124.                Create a program that shows concept of pointer.
125.                Create a program to swap two values (Pass by reference)
126.                Create a program to accept 10 numbers in an array and sort it with the help of pointer.
127.    Write a program that find maximum and its position from 10 number using array.
128.    Write a program that sort the value in ascending order in array.
129.    Write a program that generate the array of distinct or unique values from the array given by user.
130.    Write a program that calculates the total marks and percentage for 5 subject marks using array.
131.    Write a program that arrange the array values in reverse order.
132.    Write a program that perform the summation and subtraction of two matrices.
133.    Write a Program that perform the sum of rows and sum of column for n by n matrix
134.    Write a Program that perform the sum of rows and sum of column for m by n matrix
135.    Write a program that take the input of sales of  5 salesman  for 4 different quarter of year. Count the total sales perform by each salesman and sales performed during each quarter also perform the grand total sales.
136.    Write a program that perform the sum of diagonal elements of n by n matrix
137.    Write a program of spiral matrix using 2-D matrix.

Built in functions
138.                Accept one no and display its absolute value.
139.                Accept one no and display its log.
140.                Accept one no and display its square root.
141.                Get 2 no from user and display base^exp.  (2^3=8) 
142.                Get a string from user and display length of that string.
143.                Get a string from user and copy it in another variable.
144.                Get two strings from user and compare weather both are same or not.
145.                Get a string from user and display reverse of it.
146.                Get two strings from user and merge it into first string.
147.    Get a string from user and display it in lower case.
148.    Get a string from user and display it in upper case.   

User Define Function
149.    Create a user define function named sum which accept 2 arguments (of integer type) and return the sum of them.
150.    Create a user define function named avg which pass array as argument (of integer type) and return its average value.
151.    Create a user define function named evenodd which accept one argument (of integer type) and return if the number is even or odd.
152.    Create a user define function named fact which accept one argument (of integer type) and return the factorial of given number.
153.    Create a user define function named prime which accept one argument (of integer type) and display that the no is prime or not. (no need to return value)
154.    Create a user define function named triangle which accept one argument (of integer type) and display a triangle like. (If you have given 4 as argument)
1
1 2
1 2 3
1 2 3 4
155.    Create a user define function named power which accept two arguments (of integer type)  (i) base (ii) expon and display the base^expon value.
156.    Create a user define function named Sroot which accept one argument (of integer type) and display the square root of that no.
157.    Create a user define function named ASCII which accept one argument (of character type) and display ASCII value of that character.
158.    Create a user define function named CHR which accept one argument (of integer type) and display character of that ASCII value.

159.    Write a function to count the simple interest..
160.    Write a function  that count compound interest.
161.    Write a function to generate the square of any given number
162.    Write a function  which should work as a power function
163.    Write a functions to count the area of circle, triangle, rectangle and square.
164.    Write a function to print any character for n no of time.
165.    Write a function which should work as absolute function. 
166.    Write a program witch demonstrate the use of pre and post increment and decrement operator also define the use of assignment operator like +=, -= , *= , /=.
167.    Write a functions which should work like a isnum() ,isalpha() ,ischar() functions .
168.    Write a functions which should work like (1) asc() function which returns an integer value of given character(2) char() function which returns character value for given integer value.
169.    Write a function to interchange the two value a and b (Call By Reference) witch passes the 2 arguments in form of address of a and b variable with declaration like Void swap(int *, int *).
170.    Write a void function which count the area and perimeter of circle(Call By Reference) witch passes radius , address of  area variable and address of  perimeter variable with declaration like Void count(float , float *, float *)
171.    Write a function to count mean for discrete data. User has to pass only n no of values and address of first element of an array with declaration  like float mean(int *,float *)
172.    Write a function to find out maximum from of n no of values. User has to pass n no of elements and Address of first variable in an array. With declaration like int findmax(int,int *).
173.    Write a function to arrange integer values in ascending order in an array witch passes n of elements and address of  first element of  an array  with declaration like  void arrange(int,int *)
174.    Write a program that demonstrate the use of gets() and puts() .
175.    Write a program that demonstrate the use of  strcmp(), strlen(), strcpy(), strrev(), strupr(), strlwr() and strcat() built-in function.
176.    Write a program that take input of  name of 10 students  with gets() and just print them with puts() function.
177.    Write a  program or function which should work like a strlen() function.
178.    Write a  program or function which should work like a strcmp() function.
179.    Write a  program or function which should work like a strcpy() function.
180.    Write a  program or function which should work like a strcat() function.
181.    Write a  program or function which should work like a strrev() function.
182.    Write a  program or function which should work like a strupr() function.
183.    Write a  program or function which should work like a strlwr() function.
184.    Write a program that take input  names of 10 students. Arrange them in ascending order in string array.
185.    Write a program that take input paragraph of 10 lines. Count total no of word and total no of characters (Excluding blank spaces).
186.    Write a pre-processor directives which returns (1) area of circle (2) perimeter of circle
187.    Write a pre-processor directives which checks works like a (1) isdigit() (2) isalpha() functions
188.    Write a preprocessor directives which demonstrate the use of  #ifdef and  #ifndef.
189.    Write a preprocessor directives which use some symbolic directives for (&&,||,==) to operators.
Structure
190.    Create a structure named student that have member variable roll no, name, m1, m2, m3, sum, average, and grade. Program ask for roll no, name, m1, m2, m3 and calculate sum, average and grade.
191.    Create a structure named EMP that have member variables employee no, employee name, basic salary, DA, HRA, TA , PF and Gross Salary.
192.    In above structure create an array of structure.
193.    In above structure create an array of structure and use pointer.
194.    Write a program to find size of structure.
195.    Write a simple program using structure that demonstrate different type of declaration of structure variable
196.    Write a program using structure that accept rollno,name and percentage of students.
197.    Write a program that demonstrate the use of aray of structure variable
198.    Write a program that demonstrate how one structure variable can be copied into another
199.    Write a program that demonstrate the use of structure and function.
200.    Write a program that access the structure variable using pointer.
201.    Write a program that demonstrate the use of nested structure. For example
202.    struct marks                                                   struct student
{                                                        {
         int s1;                                                   int rollno;
         int s2;                                                   char name[20];
         int s3;                                                   struct mark m1;
         int tota;                                     }s1;
};
203.    Write a program that demonstrate the use of getch(),getche(),getchar() and putchar() functions.
204.    Write a program that demonstrate the use of formatted input with (%[  ]) operator.
205.    Write a program that demonstrate the use of formatted output like printf("%10d",rollno); ,printf("%10.2f",salary) and printf("%*.*s",10,5,name)
206.    Write a simple program that explain the precedence (priority) and associatively.

File Handling
207.    Write a programme to create a file.
208.     Write a programme to read a file.
209.    Write a programme to copy one file to another file.
210.    Write a programme to add data into an existing file.
211.    Create a database for a person, which includes information like person id, person name, age, phone no, height. Give the facility to add the data, read the data & person id should not be duplicate.
212.    Write a program to accept file name form command line argument and write data into it.
213.    Write a program which accept two file name form command line argument arg1 and arg2, copy the content of arg1 to arg2.
214.    Write a program to understand the use of getc(), putc().
215.    Write a program to understand the use of getch(), putch().
216.    Write a program to understand the use feof(), fgetc(), fgets(), fputc(), fputs(), fread(), fwrite(), ftell() and fseek().



1 comments:

I want If else programme..listed above as soon as possible

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More