include struct student{char name[30];int rollno;float marks;};void display(struct student *);void main(){struct student s1 = {“Raja”, 538, 92};display(&s1);getch();}void display(struct student *ptr){printf(“Student name\tRollno\tMarks\n”);printf(“%s\t\t%i\t%f”,ptr->name,ptr->rollno,ptr->marks);} OUTPUT:Student name Rollno MarksRaja 538 92.000000
Start reading C Program to Implement Structure with PointersBlog
include struct student{char name;int rollno;float marks;};struct student std_func(char, int, float);main(){struct student s1 = {‘X’, 125, 95};std_func(s1.name, s1.rollno, s1.marks);getch();}struct student std_func(char name, int rollno, float marks){printf(“Name\tRoll No.\tMarks\n”);printf(“%c\t%d\t\t%.2f”, name, rollno, marks);} OUTPUT:Name Roll No. MarksX 125 95.00
Start reading C Program to Implement Structure with Functions/* Write a C program to delete n Characters from a given position in a given string.*/ include include include void delchar(char *x,int a, int b); main(){char string[10];int n,pos,p;//clrscr(); } // Function to delete n charactersvoid delchar(char *x,int a, int b){if ((a+b-1) <= strlen(x)){strcpy(&x[b-1],&x[a+b-1]);puts(x);}} OUTPUT:Enter a string :programming9Enter the position from where you want to …
Start reading C Program to Delete Characters from Given Stringinclude void selection_sort();int a[30], n;void main(){int i;printf(“\nEnter size of an array: “);scanf(“%d”, &n);printf(“\nEnter elements of an array:\n”);for(i=0; i<n; i++)scanf(“%d”, &a[i]);selection_sort();printf(“\n\nAfter sorting:\n”);for(i=0; i<n; i++)printf(“\n%d”, a[i]);getch();}void selection_sort(){int i, j, min, temp;for (i=0; i<n; i++){min = i;for (j=i+1; j<n; j++){if (a[j] < a[min])min = j;}temp = a[i];a[i] = a[min];a[min] = temp;}} OUTPUT:Enter size of an array: 8 Enter …
Start reading C Program to Sort an Array using SELECTION SORTLinear search is also called as sequential search. All the elements need not be in sorted order like binary search. The program for linear search is written in C language. Check the other linear search articles given below Linear Search Algorithm With Example C Program to Find an Element Using Linear Search Linear Search in …
Start reading C Program for LINEAR SEARCH/* Write a C program to insert a sub-string in to given main string from a given position.*/ include include int main(){char a[10];char b[10];char c[10];int p=0,r=0,i=0;int t=0;int x,g,s,n,o;//clrscr(); puts(“Enter First String:”);gets(a);puts(“Enter Second String:”);gets(b);printf(“Enter the position where the item has to be inserted: “);scanf(“%d”,&p);r = strlen(a);n = strlen(b);i=0; // Copying the input string into another arraywhile(i …
Start reading C Program to INSERT a Sub-String in Main String at Given Position/* Write a C program that displays the position or index in the string S.*/ include include int main(){char s[30], t[20];char *found; /* Entering the main string */puts(“Enter the first string: “);gets(s); /* Entering the string whose position or index to be displayed */puts(“Enter the string to be searched: “);gets(t); /*Searching string t in string …
Start reading C Program to Find Sub String Position in Given String/* Write a C program to perform the following operations on doubly linked list.:i) Creation ii) Insertion iii) Deletion iv) Traversal in both ways*/ include include typedef struct dubll{int data;struct dubll leftlink,rightlink;}*DUBLL; DUBLL high,temp_node,low,last,pntr;int flag=0; DUBLL NodeAlloc();DUBLL Search(int,int); void CreateItem();void AppendItem();void PrintItem();void DeleteItem();DUBLL Search(int item,int flag);DUBLL NodeAlloc();void InsertItem(); main(void){int choice,Item;high=NULL;while(1){//clrscr();printf(“\n \t\t\t M A I N …
Start reading C Program to Perform Operations on Doubly Linked Listinclude int main(){int n, i, j, *p, a[10], b[10];printf(“Enter the number of elements :: “);scanf(“%d”, &n); } OUTPUT:Enter the number of elements :: 6Enter the elements : 10 20 30 40 50 60The reversed array :: 60 50 40 30 20 10
Start reading C Program to Reverse Elements in Arrayinclude int main() {int n1, n2, i, j, *p, *q, a[10], b[10];printf(“Enter the number of elements in array 1 :: “);scanf(“%d”, &n1); } OUTPUT:Enter the number of elements in array 1 :: 5Enter the elements : 1 2 3 4 5Enter the number of elements in array 2 :: 5Enter the elements : 6 7 …
Start reading C Program for MERGING of Two Arrays with out using Third Array