3. Program to search an element using linear search technique #include <stdio.h> #include<conio.h> void main() { int a[100],i,n, key,c=0; clrscr(); printf("Enter the size of array : "); scanf("%d",&n); printf("\nEnter the array elements:\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("\nEnter the elements to be searched : "); scanf("%d",&key); for(i=0;i<n;i++) { if(key==a[i] ) { c=1; break; } } if(c==1) printf("\nSearch is successful"); else printf("\nSearch is unsuccessful"); getch(); } 5. Program to implement Stack #include<stdio.h> #include<conio.h> #define N 5 int top=-1; int s[N]; push(); pop(); display(); void main() { int ch; clrscr(); do { printf("\nEnter your choice :1-push() 2-pop() 3-display() : "); scanf("%d",&ch); switch(ch) { case 1:push(); break; case 2:pop(); break; case 3:di...
Posts
Showing posts from May, 2025
- Get link
- X
- Other Apps
1.Program to Design LOG IN Form in Html. <!DOCTYPE html> <head> <title>login page</title> </head> <body> <center> <h1>student login from</h1> <form> <div> <label>Username:</label> <input type="text" required /><br> <label>Password:</label> <input type="password"required /><br> <button type="submit">login</button> <button type="button">cancle</button><br> <input type="checkbox" />remember me <a href="#">forgot...
- Get link
- X
- Other Apps
3. Find the Sum of n Natural Numbers n = int(input("Enter number: ")) sum = 0 while n > 0: sum = sum + n n = n - 1 print("The sum of natural numbers:", sum) 4. Display Multiplication Table n = int(input("Enter number: ")) for i in range(1, 11): c = n * i print(n, '*', i, '=', c) 5. Check if a Given Number is Prime or Not n = int(input("Enter number: ")) if n > 1: for i in range(2, n): if (n % i) == 0: print(n, "is not a prime number") break else: print(n, "is a prime number") else: print(n, "is not a prime number") 6. Implement Sequential Search def sequential_search(dlist, item): pos = 0 found = False while pos < len(dlist) and not found: if dlist[pos] == item: found = True else: pos = pos + 1 return found, pos print(sequential_search([11, 23, 58, 31, 56, 77, 45, 12, 65, 19], 31)) 7. Create a Calculator Program def addition(num1, num2): return num1 + num2 def subtraction(num1, num2): return...