c lab sheet

6
Kantipur City College, BE Computer 1 st Semester Computer Programming I LAB SHEET 1 1. Write a program to display name of your college by using printf() function. 2. Write a program to display name, address and phone by using '\t' in printf() function. 3. Write a program to display name, address and phone by using '\n' in printf() function. LAB SHEET 2 1. Write a program to read two integers and calculate sum, difference and product. 2. Write a program to calculate the simple interest. 3. Write a program to calculate the cube of (a+b). 4. Write a program to ask the user for the radius of a circle and calculate the area and circumference. 5. Write a program to convert the temperature value given in Celsius to Fahrenheit. 6. Write a program to enter a character in lower case and convert it upper case and vice versa.(using toupper() & tolower() functions and without using functions) LAB SHEET 3 1. Write a program to input two integer numbers and find quotient and remainder. 2. Write a program to find the addition, subtraction, multiplication, division and modulo of given two integer input using shorthand assignment operator. 3. Write a program to find the reverse of three digit integer number. 4. Write a program to find the greatest number among two given by the user using ternary operator. 5. Write a program to input two integer numbers a and b, compare them, if a is greater than b add 2 to a else add 3 to b using ternary operator. LAB SHEET 4

Upload: ramesh-shrestha

Post on 16-Jan-2016

5 views

Category:

Documents


0 download

DESCRIPTION

Complete Lab sheet of C

TRANSCRIPT

Page 1: C lab sheet

Kantipur City College, BE Computer 1st Semester Computer Programming I

LAB SHEET 1

1. Write a program to display name of your college by using printf() function.2. Write a program to display name, address and phone by using '\t' in printf()

function.3. Write a program to display name, address and phone by using '\n' in printf()

function.

LAB SHEET 2

1. Write a program to read two integers and calculate sum, difference and product.2. Write a program to calculate the simple interest.3. Write a program to calculate the cube of (a+b).4. Write a program to ask the user for the radius of a circle and calculate the area

and circumference.5. Write a program to convert the temperature value given in Celsius to Fahrenheit.6. Write a program to enter a character in lower case and convert it upper case and

vice versa.(using toupper() & tolower() functions and without using functions)

LAB SHEET 3

1. Write a program to input two integer numbers and find quotient and remainder.2. Write a program to find the addition, subtraction, multiplication, division and

modulo of given two integer input using shorthand assignment operator.3. Write a program to find the reverse of three digit integer number.4. Write a program to find the greatest number among two given by the user using

ternary operator.5. Write a program to input two integer numbers a and b, compare them, if a is

greater than b add 2 to a else add 3 to b using ternary operator.

LAB SHEET 4

1. Write a program to find the odd or even number using if else statement.2. Write a program to find the largest of three integer numbers using nested if

statement.3. Write a program to prints the day depending upon the number inputted by the user

using else if ladder.4. Write a program to prints the day depending upon the number inputted by the

user. (using switch case)5. Write a program to calculate sum, difference, multiple, division of two numbers.

[Design menu and use switch case.]6. Write a program to print the numbers from 10 & 30 by using goto statement.7. Write a program to find the vowel and consonant of a given character. [Using IF

statement.]8. Write a program to find the given character is alphabet or numeric. If alphabet

then check uppercase or lower case, if in lower case then convert it into upper and vice-versa.

Page 2: C lab sheet

Kantipur City College, BE Computer 1st Semester Computer Programming I

LAB SHEET 5

1. Write a program to find the sum of number from 1 to 50.2. Write a program to enter any digit integer number, reverse it and check whether it

is palindrome or not. ( Use while() loop)3. Write a program to enter an integer number and check whether it is Armstrong or

not.4. Write a program to check whether a user inputted number is perfect or not.5. Write a program to find sum of even numbers from 2 to 100.6. Write a program to calculate the value of x to the power y.7. Write a program to generate FIBONACCI number up to nth position8. Write a program to print the factorial of number (n) entered from keyboard.9. Write a program that checks given number is prime or not.10. Write a program to generate multiplication table from 1 to 10.

LAB SHEET 6

1. Write a program to accept any number 'n' and print the sum of square of all numbers from 1 to n.

2. Write a program to display the Armstrong number from 100 to 200.3. Write a program to enter the value of n1 and n2 and find and display the prime

number between n1 and n2. 4. Write a program to generate the following output:

a. b. c.

d. e. f.

LAB SHEET 7

1. Write a program to accept any number 'n' & print the cube of all numbers from 1to n which is exactly divisible by 3.

2. Write a program to find the leap year between 1900 and 2000..3. Write a program to display following output:

12 23 3 34 4 4 45 5 5 5 5

** ** * ** * * ** * * * *

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 1 2 3 4 1 2 31 21

1 1 1 1 1 2 2 2 2 3 3 3 4 4 5

1 1 2 1 2 3 1 2 3 4 1 2 3 4 5

12 2

3 3 3 4 4 4 4 5 5 5 5 5

Page 3: C lab sheet

Kantipur City College, BE Computer 1st Semester Computer Programming I

LAB SHEET 8

1. Write a program to enter values in array called myarray of size 15 and display the elements of array.

2. Write a program to enter values in array called myarray of size 10 and display the sum of elements of array.

3. Write a program to find the largest and smallest value in array.4. Write a program to sort the number in ascending order.5. Write a program to add the numbers in two arrays and assign in next array.

LAB SHEET 9

1. Write a program to evaluate to following polynomial equation. p(x)=a0x^o+a1x^1+a2x^2+...........a(n-1)x(n-1)^(n-1)+anx^n

2. Write a program to transpose the matrix.3. Write a program to add two matrix called matrix_a and matrix_b and put the

result in matrix_c.Write a program to find the product of two matrices

LAB SHEET 10

1. Write a program to generate FIBONACCI number up to nth position. Using function.

2. Write a program to ask the user for two numbers and print the sum, difference and product of two numbers.

a. Function without argument, without return type.b. Function with argument, without return type.c. Function with argument, with return type.d. Function without argument, with return type.

3. Write a program to read two integers a and b and calculate (a+b)^3 using function.

4. Write a program to calculate the factorial of a given number using function declaration.

. LAB SHEET 11

1. Write a program to read the string from the user and display its length.(using strlen() and without using strlen())

2. Write a program to enter a string and copy it to another string .( using strcpy() and without using strcpy())

3. Write a program to enter two string and compare them to check whether they are same or not.(using strcmp() and without using strcmp()).

Page 4: C lab sheet

Kantipur City College, BE Computer 1st Semester Computer Programming I

4. Write a program to enter two string and concatenate one string to another(using strcat() and without using strcat());

5. Write a program to enter a string reverse it and check whether it is palindrome or not.

6. Write a program to sort the 10 strings in alphabetical order.7. Write a program to find the longest string among 10 strings.8. Write a program to display the first and last character of 5 strings.

LAB SHEET 12

1. Write a program to clear the concept of swapping call by reference.2. Write a program to accept 10 numbers and print the total with the use of pointer.3. Write a program to test the word palindrome or not.4. Create a structure called ‘employee’ with suitable members. Write a program to

ask the value for structure members and short them with the basis of salary.(use pointer for all operation)

5. Write a program to allocate the memory (memory size should given by the user) for numbers given by the user and sort them with the use of pointer

LAB SHEET 13

1. Program to define a structure struct personal that would contain person name, address, phone number, date of joining and salary. WAP to read this information for one person from the keyboard & print the same on the screen.

2. Program to define a structure 'Student',that describes attributes like 1.char firstname[20], 2. char lastname[20], 3. int rollno, & 4. float persentage. using this structure, declare array of 3 student & WAP to read the information about each student & calculate the average percentage.

3. A point has x-axis & y-axis. Define a struct called point with suitable attribute. WAP to accepts two points from the user & calculate the distance between the two points [d=sqrt((x2-x1)^2+(y2-y1)^2)]

4. Program to define a structure called 'Time' with suitable members, and read two times from user and perform addition between these times..