• No results found

157 Value Meaning

In document Programming in C (Page 163-167)

0 - Beginning of file 1 - Current position of PTR 2 - End of File fseek(fp,5L,0); fseek(fp,4L,1); fseek(fp,-4L,2);

If seek operation is successful, then it will return a 0 otherwise it returns 1.

Ques. WAP to implement file handling.

#include<stdio.h> #include<conio.h> void main() { FILE *fp; char c; printf("Data input \n\n"); fp=fopen("Inputfile.txt","w"); while((c=getch())!=EOF) { putc(c,fp); } fclose(fp); getch(); }

Ques. WAP to create a file and open that file.

#include<stdio.h> #include<conio.h> void main() { FILE *f1,*f2; char c,fname[10]; clrscr(); f1=fopen("fname","r"); if(f1==NULL) {

printf("File Can't Open"); exit();

}

f2=fopen("D:\fname2.txt","w"); if(f2==NULL)

{

printf("File Can't Open"); fclose(f1); exit(); } while(1) { c=getc(f1); if(c==EOF) break;

PROGRAMMING IN C

P

ANKAJ

G

ILL

[email protected]

158

else fputc(c,f2); } fclose(f1); fclose(f2); getch(); }

P

PRROOGGRRAAMM

IINNDDEEXX

Sr. No. Program Page No. 1. My First Program. 8

2. Write a Program to get the Roll No. and Fee of a student and showing it afterwards using

integer functions in your program. 9

3 Example Program on Arithmetic Operator. 21

4 Example Program of Conditional Operator. 24

5 Example programof Left Shift & Right Shift Operator. 25

6 Example Program of Bitwise And ‘or’ OR. 26

7 Example program of Compliment Bitwise Operator. 27

8 Example Program of Bitwise Exclusive-OR(XOR). 27

9 Revision Program for Operators. 28

10 Make a program to find out the area of a circle. 29

11 To find the character of ASCII Code. 29

12 To find out the Simple Interest. 30

13 Make a program to find out Compound Interest. 30

14 Make a program to swap 2 integers by the help of third variable. 30

15 Make a program to swap 2 integers without the help of third variable. 31

16 Make a program to find out whether the no. is even or odd by using conditional operators. 31

17 Program for demonstration of Console I/O Functions. 35

18 Make a program to reverse the 5 digit Number. 36

19 Make a program to find out the sum of five digits number. 36

20 WAP to find S.I. when rate is 8% if time is less then or equal to 3 & rate is 12% if time is

greater than 3. 39

21 WAP to calculate the total electricity bill. If the person is male than he will get a discount of 3% on the bill when the bill is more than Rs. 4000, and if the person is female than she will get 3% discount if the bill amount is less than Rs. 4000 and 5% if the bill amount is more than Rs. 4000.

40 22 Make a program that uses else-if statement to validate the users input to be in the range 1-

10. 44

23 Make a program using Nested-if statement to find the greater number among 3 numbers without the help of logical operators. 45

24 Make a program using Nested-if statement to find the greater number among 3 numbers

and with the help of logical operators. 45

25 Make a program to find out that the no. entered is divisible by another no. or not, using if

else statement. 46

26 Make a program to check for upper and lowercase letters. 46

27 Make a program to conclude the result of a student by taking marks of 5 different subjects. 47

28 WAP to check whether the number entered is a prime number or not. 53

29 WAP to print prime number between 100 to 200. 53

31 Write a program to find the table of any integerentered by the user. 54

32 Make a program to reverse the table of any integerentered by the user. 54

33 Make a program to draw a right angle triangle by the help of * sign. 55

34 Make a program to draw a Triangle with the help of integers. 55

35 Make a program to draw a triangle with the help of triangle. 56

36 Make a program to draw triangle, square & rectangle by taking input from the user. 56

37 Make a program to draw the mirror image of a right angle triangle. 58

38 Make a program to make a pattern given below with your name between the pattern. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 59

39 Make a program to find any integer’s table using while loop. 60

40 Write a program to find the Armstrong number. 60

41 WAP to enter a no. and its power and show the result. 61

42 WAP to enter a decimal no. and convert into binary no. 61

43 WAP to show the Fibonacci series upto 100. 61

44 WAP to convert binary number into decimal number. 62

45 WAP to convert any number into binary number. 62

46 WAP to convert Decimal number into any number. 64

47 Example Program for implementing array of integers . 67

48 Example Program for implementing array of floating point data. 68

49 WAP to implement the operation of searching in 1-D array. 71

50 WAP to implement the operation of sorting. 72

51 WAP to implement the operation of Insertion. 73

52 WAP to implement the operation of deletion. 74

53 WAP to implement the operation of merging. 74

54 WAP to print a Matrix. 77

55 WAP to add two matrixes. 78

56 WAP to subtract a matrix from another matrix. 79

57 WAP to multiply two matrices. 81

58 WAP to implement print the list of student name using string. 83

59 WAP to add two nos. by using return statement. 85

60 WAP to implement Call by Value for swapping two integers. 86

61 WAP to implement Call by Reference for swapping two integers. 87

62 Program to print factorial of any no. entered by user using recursion. 88

63 Demonstration of passing array to a Function by call by value. 88

64 Demonstration of passing array to a function by call by reference. 89

65 WAP to implement Command Line Argument. 90

66 WAP to implement print Command Line Argument. 91

67 WAP to implement pointers. 96

69 WAP to implement Poitners & Strings. 97

70 WAP to implement print the list of student name using string pointer. 98

71 WAP to implement return pointers from function. 99

72 WAP to implement the sum of array elements using pointers & show there addresses. 100

73 WAP to print the sum and average of arrays element by using pointerand the size of array

element entered by user. 101

74 WAP to find the smallest element in an array of n elements byusing pointer. 101

75 WAP to print the value using array of pointer. 102

76 Example Program of Using Pointer Arithmetic with Arrays. 103

77 Example Program of Using Modifying Variables Using Pointers. 104

78 Example Program of Using Generic Pointers(void Pointer). 104

79 WAP to implement allocate memory using malloc function to find greater element in array. 107

80 WAP to implement concept of dynamic memory allocation by using pointer & find out the

Sum of n elements of array using dynamic memory allocation. 107

81 Example Program of Some String Subroutines. 109

82 Write a C program to copy one string to another, using pointers and without using library

functions. 111

83 WAP to reverse a string without using reverse function. 111

84 WAP to reverse a string using for loop. 112

85 WAP to implement convert a string in lowercase character without using strlowr function. 112

86 WAP to con-centate 2 strings of diff. length. 113

87 WAP To check while string is palindrome or not. 113

88 WAP to implementing <ctype.h>. 117

89 WAP to implement <ctype.h> while using alnum() for testing for numerical entry. 117

90 WAP to implement define structure type struct employee that would contain employee name,age,d.o.b,salary,to read this information for three employee from the keyboard and print the same on screen.

122 91 Example Program of using Array of Structures. 124

92 WAP to maintain record of file customer in a bank using array of structure. 125

93 WAP to implement copy and compare to structure variable. 126

94 Example Program of Using Pointers and Structures together. 127

95 WAP to implement pointer and structure together to store a student info. 128

96 WAP to implement Nested and Named Structures. 129

97 WAP to maintain record of student (name,d.o.b,address) using nesting structure. 130

98 WAP to enter the data of student using array of structure & nesting structure. 132

99 WAP to accessing of union member and use of size of operator. 136

100 WAP to renaming the structure data type using typedef. 138

101 WAP to implement bitfield in a record of employe. 139

102 WAP to maintain the record of employee in a payroll system using enumerated data type

department can have four possible values assembly, manufacturing,accounts,store. 141

103 A Simple Program to Read from a file. 155

104 WAP to implement file handling. 157

In document Programming in C (Page 163-167)