0% found this document useful (0 votes)
1K views11 pages

Final CE141 CCP Practical List

This document contains a practical list for a Computer Concepts and Programming subject with 14 practical tasks. The practical tasks cover topics like I/O operations, decision making, looping, functions, arrays, strings, pointers, structures and more. Students are expected to write C programs to solve problems related to calculating areas, currency conversion, ratios, discounts, conditional statements, data types and more.

Uploaded by

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

Final CE141 CCP Practical List

This document contains a practical list for a Computer Concepts and Programming subject with 14 practical tasks. The practical tasks cover topics like I/O operations, decision making, looping, functions, arrays, strings, pointers, structures and more. Students are expected to write C programs to solve problems related to calculating areas, currency conversion, ratios, discounts, conditional statements, data types and more.

Uploaded by

mann123456789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY

CHANDUBHAI S. PATEL INSTITUTE OF TECHNOLOGY


DEVANG PATEL INSTITUTE OF ADVANCED TECHNOLOGY &
RESEARCH
U & P U. Patel Department of Computer Engineering
CSPIT F.Y. B.Tech (CE/IT/EC)
DEPSTAR F.Y. B.Tech (CE/IT/CSE)

Subject Name: Computer Concepts & Programming Semester : I


Subject Code: CE141 Academic year: 2017-18

Practical List
Sr.
No. Aim of the Practical

Knowledge Required: Constants, Variable & Data Types, Operators

Write a C program that will output this passage by Michael Singer. Make sure your output looks
exactly as shown here (including spacing, line breaks, punctuation, and the title and author). Use
Required Escape Sequence and ASCII Value.

1.

There are three shapes in the output: Smiling Face, Diamond & Heart.
The ASCII Value for Smiling face is 1.

The ASCII Value for Diamond is is 4.

The ASCII Value for Heart is is 3.


In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of
literate men is 35 of the total population, write a program to find the total number of illiterate men and
women if the population of the town is 80,000.
Programme:
#include<stdio.h>
2. #include<conio.h>
main()
{
long int pop=80000,mp,lp,lmp,popm,popw,poplm,poplw,popim,popiw,popl;
popm=(pop*52)/100;
printf("the number of men in city is:%ld\n",popm);
poplm=(pop*35)/100;
printf("The number of literate men in city is:%ld\n",poplm);
popim=popm-poplm;
printf("The number of illeterate men is :%ld\n",popim);
popw=pop-popm;
printf("The number of women in city is:%ld\n",popw);
poplw=popw-poplm;
printf("The number of literate women in city is:%ld\n",poplw);
popiw=popw-poplw;
printf("The number of illeterate Women in city is:%ld\n",popiw);
getch();
}
OUTPUT:

Write a program to calculate area of two circle. (r2). Use Preprocessor directive named macro
expansion for the symbol (Symbolic Constant) without argument and with argument. Use
typedef to rename the float datatype.
Programme:
/*programme to calculate area of circle*/
#include<stdio.h>
#include<conio.h>
#define PI 3.14
main()
{
3. int r1,r2;//it will
float area1,area2;//it will
printf("Enter the value of radius of first circle:");//it will give the message to enter value
of radius
scanf("%d",&r1);//it will accept value of radius
area1=PI*r1*r1;//it will calculate value of area
printf("Area of your first circle is:%f\n",area1);//it will print the message of area
printf("Enter the value of radius of second circle:");
scanf("%d",&r2);
area2=PI*r2*r2;
printf("Area of second circle is:%f",area2);
getch();
}
OUTPUT:

Write a program to do following:


(a) Input an amount and convert it into rupees and paisa. (For Ex. 25.67 Rs = 25 Rs and 67
4. Paisa).(Implicit type Conversion)
(b) Input No of female and No of male and calculate the ratio of females to males in a town. No of
female and No of male are in int and ratio is in float. (For Ex. No_of_Female = 10 &
No_of_Male = 7 then ratio = 1.43).(Explicit type Conversion)
Knowledge Required: I/O Operations , Decision Making and Branching, Decision Making and
Looping

While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than
5. 1000.If quantity and price per item are input through the keyboard, write a program to calculate the
total expenses. Use Simple If statement.

6. Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on
one straight line. Use fabs() function of < maths.h> header file. Use ifelse statement.
If the three sides of a triangle are entered through the keyboard, write a program to check whether the
triangle is valid or not. The
7. triangle is valid if the sum of two sides is greater than the largest of
the three sides. Use nested ifelse statement.

An Insurance company follows following rules to calculate premium.


(1) If a persons health is excellent and the person is between 25 and 35 years of age and lives in a city
and is a male then the premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2
lakhs.
8. (2) If a person satisfies all the above conditions except that the gender is female then the premium is
Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.
(3) If a persons health is poor and the person is between 25 and 35 years of age and lives in a village
and is a male
then the premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000.
(4) In all other cases the person is not insured.
Write a program to output whether the person should be insured or not, his/her premium rate and
maximum amount for which he/she can be insured. Use Elseif Ladder.
Write a program using Conditional Operators to determine whether Year entered through the
keyboard is a leap year or not. An year occurring once every four years, which has 366 days including
9. 29 February is called a leap year. (Hint: The year is Leap if it is fully divisible by 100 & 400 else the
year is leap if it is fully divisible by 4).

Write a program to input a character using getchar() and print the character using putchar() and check
10. the character category. Also convert uppercase alphabet to lower case and vice versa. (Use Character
Test Functions : isalnum(), isalpha(), isdigit(), islower(), isprint(), ispunct(), isspace(), isupper()) and
(toupper() & tolower()) of <ctype.h> header file.
Write a program to find the grace marks for a student using Switch Statement. The user should enter
the class obtained by the student and the number of subjects he has failed in.
1. If the student gets first class and the number of subjects he failed in is greater than 3, then he
does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the
grace is of 5 marks per subject.
2. If the student gets second class and the number of subjects he failed in is greater than 2, then
he does not get any grace. If the number of subjects he failed in is less than or equal to 2 then
11. the grace is of 4 marks per subject.
3. If the student gets third class and the number of subjects he failed in is greater than 1, then he
does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5
marks per subject.

If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to
12. determine the youngest of the three. Use Nested Switch Statement. (This Program is a part of
Practical List but it is an Homework for students but explain the concept in Lab not the logic)
Write a program to calculate following series using if and goto statement.
13. 12+22+.n2

Write a program to find number of 1s in the binary representation of a number. For example, the
14. binary of 5 is 0000 0000 0000 0101 contains two 1s. Use for loop. Use Bitwise AND & and Shift
Right >> operator.
An Armstrong number is an n-digit number that is equal to the sum of the nth powers of its
15. individual digits. For example, 153 is an Armstrong number because it has 3 digits and 13+ 53+33
=153. Similarly 1634 is an Armstrong number because it has 4 digits and 14+ 64+34 + 44 = 1634.
Write a program to find whether the entered number is Armstrong or not using While Loop.
Write a menu driven program which has following options:
1. Prime or not
16. 2. Perfect number or not
3. Factorial of a number
4. Exit
Use do...while statement so that the menu is displayed at least once. Also use Switch statement.
Write a program to print the following pattern using Nested for loop.
(a)
A B C D E F G F E D C B A
17.
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

(b)

Write a program for a match-stick game between the computer and a user. Your Program should ensure
that the computer always wins. Rules for the games are as follows:
There are 21 match-sticks.
The computer asks the player to pick 1, 2, 3, or 4 match-sticks.
After the person picks, the computer does its picking.
18. Whoever is forced to pick up the last match-stick loses the game.
Use while loop, break and Continue Statements.

To understand the above game in a better way visit the following link:
http://atozmath.com/Games/21MatchStick.aspx

Knowledge Required: Arrays & Strings

19. Write a program to sort elements of an array in ascending order using Bubble Sort.
Write a program that reads an M x N matrix A and prints its elements in spiral order. You should start
from the element in the 0th row and 0th column in the matrix and proceed in a spiral order as shown
below.

1 2 3 4

20. 567 8

9 1011 12

131415 16

Output for the above matrix:1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10


Write a program to find whether two given strings are permutations of each other. A string str1 is a
21. permutation of str2 if all the characters in str1 appear the same number of times in str2 and str2 is of
the same length as str1. For example if two strings are kindness and ksnisden the answer is Yes.
Write a program that would sort a list of names of fruits in alphabetical order. For example 5 names
Orange, Pineapple, Grapes, Banana, Mango should sort the names as follows:

Banana
22. Grapes
Mango
Orange
Pineapple

Knowledge Required: User-Defined Functions, Structures & Union

Write a Program to print the table of Squares and Cubes of 1 to 10.


The Program uses the following four Function:
23. Functions Category
printline(): draws the Function with No Arguments, No return
line using - character. type
printnum() : prints Function with Arguments ,No Return type
number, square and
cube.
square() : computes Function with Arguments, with Return
square of a number. Type
cube() : computes cube Function with Arguments, with Return
of a number. Type

The output should look like the below diagram:

Write a program to calculate nCr using Function with No arguments But with Return type.
24. (Hint: nCr = n! / ((r!) (n r)!)). (This Program is a part of Practical List but it is an Homework
for students but explain the concept in Lab not the logic)
Write a program to pass a number entered through keyboard as an argument to user-defined functions
25. and find the factors of a number and check whether the factors are prime or not using Nested
Functions.

Write a program to generate Fibonacci series using Recursive Function. In a Fibonacci sequence the
26. sum of two successive terms gives the third term.
1 1 2 3 5 8 13 .

Write a Program to compute the standard Deviation of N Numbers using Arrays & Function.

For example suppose we have following numbers:


9, 2, 5, 4, 12, 7, 8, 11
27.
To calculate the standard deviation of these numbers:

1. First find out the simple average of the numbers which is also known as mean and is denoted by
.
There are 8 numbers so the average would be
= (9+2+5+4+12+7+8+9)/8 = 7
2. Then for each number: subtract the Mean and square the result
(9 7)2 = (2)2 = 4
(2 7)2 = (-5)2 = 25
(5 - 7)2 = (-2)2 = 4
(4 - 7)2 = (-3)2 = 9
(12 - 7)2 = (5)2 = 25
(7 - 7)2 = (0)2 = 0
(8 - 7)2 = (1)2 = 1
(9 - 7)2 = (2)2 = 4
3. Then calculate average of those squared differences.

Average of squared difference = (4+25+4+9+25+0+1+4)/8 = 9

4. Take the square root of that and we are done!

= =

Write a Program to reverse a string using Recursive Function and check whether it is
28. palindrome or not. (This Program is a part of Practical List but it is an Homework for students
but explain the concept in Lab not the logic)
Write a Program to find the upper triangle in the given matrix. Consider the following 4 x 4 Matrix.
If all the elements denoted by X are non-zero then the matrix has upper
X X X X
triangle. For the upper triangle, all the elements of principle diagonal and
29. 0 X X X above must be non zero. Pass two dimensional arrays to the function.

0 0 X X

0 0 0 X

Write four small programs to illustrate the use of 4 storage class specifiers auto, static, register
30. and extern. (This Program is a part of Practical List but it is an Homework for students but
explain the concept in Lab not the logic)
Create a Structure called library to hold accession number, title of the book ,author name, price of the
book and flag indicating whether the book is issued or not.(flag = 1 if the book is issued , flag = 0
31. otherwise). Write a program to enter data of one book and display the data. Write this same program
with Union also.

Define a structure called Result for students. Structure will have members like Roll number, marks for
three subjects and total of three subjects. Write a program to enter data for 5 students and display the
merit list of students. Use Array of Structures. For example, if Roll No and marks of three subjects of
each student are entered through the keyboard , the output should look like the following:

32.

33. Write a program to read and display information of salary of an employee using Structure within a
Structure. Outer structure contains members like name of employee, designation, department name,
basic pay and inner structure contains dearness allowance, house_rent allowance and city_allowance.
Calculate the total salary of one employee.

Define a structure named Date that contains three members day, month and Year. Write a program
that compares two given dates. If the dates are equal then display message as Equal otherwise
34. Unequal. Write a function Check_Date to check whether the entered date is proper or not. The date
is proper if day is between 1 and 31, month is between 1 and 12 and year is between 1000 and 9999.
(Structures & Functions)

Knowledge Required: Pointers, File Management, Dynamic Memory Allocation

Write a program to read the marks of 10 students for the subject CE141 Computer concepts and
Programming and computes the number of students in categories FAIL, PASS, FIRST CLASS and
DISTINCTION using Pointers and Arrays.
Marks Categories
70 or Above DISTINCTION
35. 69 to 60 FIRST CLASS
59 to 40 PASS
Below 40 FAIL
For example if following marks of 10 students are entered:
34 56 78 98 12 31 67 75 91 23
Then the output should be
DISTINCTION 4 FIRST CLASS 1 PASS 1 FAIL 4
Write a program that extracts part of the given string from the specified position. For example, if the
string is Workshop on Cloud Computing, then if from position 5, 4 characters are to be extracted then
36. the program should return the string as shop. 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. (Pointers and Strings)

Write a program that uses 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.

char *str[ ] = {
"We will teach you how to...",
"Move a mountain",
"Level a building",
37.
"Erase the past",
"Make a million",
"...all through C!"
};

For example if str1 contains "mountain" and str2 contains "car", then the second string in str
should get changed to "Move a car".

(Array of Pointers)
Write a program which performs the following tasks:
initialize an integer array of 10 elements in main( )
38. pass the entire array to a function modify( )
in modify( ) multiply each element of array by 3
return the control to main( ) and print the new array elements in
main( )
Above program should be done in two ways: call by value and call by address and illustrate the
difference between them. (Pointers as Function Arguments)

Write output for the following programs:


1. (Pointers to Functions)

#include<stdio.h>
void display();
int main()
{
void (*func_ptr)();
func_ptr=display;
printf("Address of functions display is %u\n",func_ptr);
(*func_ptr)();
return 0;
}
void display()
{
puts("By helping others, we help overselves!!");
}
2. (Functions Returning Pointers)
char *copy (char*,char *);
int main()
39. {
char *str;
char source[] = "Kindness";
char target[10];
str=copy(target,source);
printf("%s\n",str);
return 0;
}
char *copy(char *t,char *s)
{
char * r;
r = t;
while(*s!='\0')
{
*t=*s;
t++;
s++;
}
*t='\0';
return(r);
}
An automobile company has serial number engine parts starting from AA0 to FF9. The other
characteristics of parts to be specified in structure are year of manufacturing, material and quantity
40. manufactured.
(a) Specify a structure to store information corresponding to part.
(b) Write a program using pointer to retrieve information on parts with serial numbers between
BB1 and CC6. (Pointers and Structures)

Write a program that takes contents of a file and copy them into another file and print it on the screen.
41. Use feof () functions to detect the end of file and ferror() function to detect if there is an error in
opening the file.
Write a program to create a file named ALPHABETS which consists of all 26 letters ABCXYZ and
42. prints the contents of the file in reverse order ZYX.CBA on the screen. Use the function ftell(),
fseek() and rewind().
Write a program to open a file name INVENTORY and store in it the following data. Use fprintf() and
fscanf() functions.
Item
Number Price Quantity
Name
43.
AAA1 111 17.5 100

BBB2 125 35 50

CCC3 150 50 200

Two files Data1 and Data2 contains sorted list of integers. Write a program to produce file Data3
44. which holds a single sorted, merge list of these two list. Use command line argument to specify the
file name.
Write a program to enter N numbers into array and sort the second half of the array using function
sort(). Enter the size of the array through keyboard. (Dynamic Array). Use malloc () to allocate
memory and use free() to free the memory after the use.
45. For example if input is
5 13 24 67 45 34
Output should be
5 13 24 34 45 67
46. Write a program using to store a character string in a block of memory space created by calloc () and
then modify the same to store a larger string using realloc () function. (Dynamic Array).
TOTAL LAB HOURS

You might also like