Nội dung text C programming Lab 3.pdf
Prepared by shree Krishna Kafle www.unibytes.xyz 1 | P a g e Don’t Forget to Follow Uni Bytes Table of Contents LAB 1............................................................................................................................................................ 3 1. Write a program to print 'Hello world' using c programming language............................................. 3 2. Write a program to print value of variable using format specifier..................................................... 4 3. Write a program to swap value between two variables..................................................................... 5 4. Write a program to get input from user and print user input values. ................................................. 6 LAB 2............................................................................................................................7 1. Write a program to perform addition operation using c programming.............................................. 7 2. Write a program to perform subtraction operation using c programming.......................................... 8 3. Write a program to perform multiplication operation using c programming..................................... 9 4. Write a program to division operation using c programming.......................................................... 10 5. Write a program to calculate square from user input integer........................................................... 11 LAB 3......................................................................................................................12 1. Write a program to calculate area of circle...................................................................................... 12 2. write a program to calculate area and parameter of circle. .............................................................. 13 3. write a program to calculate sum and average by reading 3 integers from user input..................... 14 4. Write a program to calculate Simple Interest ................................................................................. 15 5. Write a program to read Celsius from user input convert it into Fahrenheit.................................... 16 LAB 4 .....................................................................................................................17 1. Write a program to check number enter by user is positive or negative.......................................... 17 2. Write a program to print appropriate message................................................................................. 18 3. Write a program to print you are illegible for voter id or not .......................................................... 20 4. Write a program to determine even or odd integers by user input................................................... 21 5. Write a program to check complete divisibility of number enter by user........................................ 22 6. Write a program to determine the character entered is vowel or consonant.................................... 23 7. write a program to read age from user input & print message......................................................... 24 8. Write a program to print grade by user input marks........................................................................ 25 9. Write a program to read 3 integers and print largest among three................................................... 27
Prepared by shree Krishna Kafle www.unibytes.xyz 2 | P a g e Don’t Forget to Follow Uni Bytes 10. Wap to read digit from user & print in word. .............................................................................. 28 11. Wap to read character from user and print if it is vowel or not ................................................... 30 12. Wap to read integer from user and perform operation according to number............................... 32 13. Wap to print "Hello world" 10 times using for loop.................................................................... 33 14. Wap to print sum of first 10 numbers using for loop.................................................................. 34 15. Wap to read integer from user then, calculate and print power using for loop............................35 16. Wap to print sum of first ten numbers using for loop.................................................................. 36 17. Wap to read integer from user then, calculate & print its factorial using for loop....................... 37 18. Wap to print Fibonacci series...................................................................................................... 38 LAB 5 ................................................................................................................ 39 1. Wap to read number from user and then calculate sum of digits in it using while loop. ................ 39 2. Wap to read number from user and calculate occurrence of digit using 'while-loop'...................... 40 3. Wap to read number from user and calculate reverse of number using 'while-loop' .......................41 4. Wap to read a number from user then print multiplication table using 'do while loop' ................... 42 5. Wap to read a number from user if entered ZERO restart the program........................................... 43 6. Wap to print symbolic pattern. ........................................................................................................ 44 7. Wap to print numeric pattern:.......................................................................................................... 45 8. Wap to print pattern using keyword 'continue' ................................................................................ 46 9. Wap to read integer in array and print its value............................................................................... 47 10. Wap to read integer in array and calculate sum and average of numbers in array........................... 48 11. Wap to read integers in array & print square of integer in array ..................................................... 49 12. Wap to read 10 integers in array and print occurrence of given array............................................. 50 13. Wap to read 10 integers in array and print largest integer from array ............................................. 51 14. Wap to read 10 integers from user and sorts integer element in array............................................. 52
Prepared by shree Krishna Kafle www.unibytes.xyz 3 | P a g e Don’t Forget to Follow Uni Bytes LAB 1 1. Write a program to print 'Hello world' using c programming language Objective: To display "Hello World" using c programming Theory: In c programming to print "Hello World" we use header file declaration & main method. After that we print "Hello World" by using print f() function. Program: #include # include void main() { printf("Hello World"); getch(); } Output: Conclusion: We print "Hello World" successfully by using c programming.
Prepared by Shree Krishna Kafle www.unibytes.xyz PrepP 4 | P a g e Don’t Forget to Follow Uni Bytes 2. Write a program to print value of variable using format specifier. Objective: To display value of variable using format specifier. Theory: In c programming to print value of variable, at first we put header file and file declaration and main method. After that we taken variable int , float & char and by using printf() to display the program. Program: #include # include void main() { int x = 10; float y = 2.33; char c ='s'; printf("x=%i\n y=%f\n c=%c",x,y,c); getch(); } Output: Conclusion: we print successfully value of variable using format specifier.