Practical Projects Questions (12)

  1. WAP to input two number and display its sum using function.
#include <stdio.h>
#include<conio.h>
int add(int , int);
void main() 
{
    int num1, num2, sum;
    printf("Enter the first number: ");
    scanf("%d", &num1)
    printf("Enter the second number: ");
    scanf("%d", &num2);
    sum = add(num1, num2);
    printf("The sum of %d and %d is %d\n", num1, num2, sum);
    getch();
}
int add(int a, int b) 
    return a + b;
}

 
  1. WAP to check whether the entered number is odd or even using function
#include <stdio.h>
#include <conio.h>
char checkEvenOdd(int);
void main()
{
    int num;
    printf("Enter an integer number: ");
    scanf("%d", &num);
    char result = checkEvenOdd(num);
    if(result == 'E')
    {
        printf("%d is even.", num);
    }
    else
    {
        printf("%d is odd.", num);
    }
    getch();
}
char checkEvenOdd(int num)
{
    if(num % 2 == 0)
    {
        return 'E';
    }
    else
    {
        return 'O';
    }
}
Another Method
#include <stdio.h>
#include <conio.h>
const char *checkEvenOdd(int);
void main()
{
    int num;
    printf("Enter an integer number: ");
    scanf("%d", &num);
    const char* result = checkEvenOdd(num);
    printf("%d is %s.", num, result);
    getch();
}
const char* checkEvenOdd(int num)
{
    if(num % 2 == 0)
    {
        return "Even";
    }
    else
    {
        return "Odd";
    }
}
  1. WAP to print the greatest number among three numbers using function.
#include <stdio.h>
#include <conio.h>
int findMax(int, int, int);
void main()
{
    int num1, num2, num3;
    printf("Enter three numbers: ");
    scanf("%d %d %d", &num1, &num2, &num3);
    int max = findMax(num1, num2, num3);
    printf("The maximum of %d, %d and %d is %d.", num1, num2, num3, max)
    getch();
}
int findMax(int num1, int num2, int num3)
{
    int max = num1;
    if(num2 > max)
    {
        max = num2;
    }
    if(num3 > max)
    {
        max = num3;
    }
    return max;
}
  1. WAP to calculate the cumulative sum of natural number up to n using function.
#include <stdio.h>
#include <conio.h>
int sum(int);
void main() {
    int n;
    printf("Enter a positive integer: ");
    scanf("%d", &n);
    int result = sum(n);
    printf("The sum of natural numbers up to %d is %d.\n", n, result);
    getch();
}
int sum(int n) {
    int s = 0;
    for (int i = 1; i <= n; i++) {
        s += i;
    }
    return s;
}
  1. WAP to calculate the factorial of ‘n’ number using function.
#include <stdio.h>
#include <conio.h>
int factorial(int);
void main() {
    int n;
    printf("Enter a non-negative integer: ");
    scanf("%d", &n);
    if (n < 0) {
        printf("Error: factorial is not defined for negative numbers.\n");
    } else {
        int result = factorial(n);
        printf("%d! = %d\n", n, result);
    }
    getch();
}
int factorial(int n) {
    if (n == 0 || n == 1) {
        return 1;
    } else {
        return n * factorial(n-1);
    }
}
  1. WAP to display the Fibonacci series of ‘n’ number using function.
#include <stdio.h>
#include <conio.h>
void fibonacci(int);
void main() {
    int n;
    printf("Enter a positive integer: ");
    scanf("%d", &n);
    if (n < 1) {
        printf("Error: invalid input.\n");
    } else {
        fibonacci(n);
    }
    getch();
}
void fibonacci(int n) {
    int first = 0, second = 1, next;
    printf("Fibonacci series up to %d: %d, %d", n, first, second);
    for (int i = 3; i <= n; i++) {
        next = first + second;
        printf(", %d", next);
        first = second;
        second = next;
    }
    printf("\n");
}
  1. WAP to calculate the factorial of ‘n’ number using recursive function.
  2. WAP to display the 10th term of Fibonacci series using function.
  3. WAP to display the Fibonacci series up to ‘n’ number using recursive function.
  4. WAP to check whether the number is prime or composite using function.

  1. WAP to input the name, class, roll no and section of 20 students using structure.
  2. WAP to input employee name, position, salary and id of ‘n’ employee using structure.
  3. WAP to input name, position, employee id and salary of ‘n’ employee using array of structure.
  4. WAP to input name and marks of ‘n’ students using structure and sort them in descending order with respect to their marks and display them.
  5. WAP to input name and marks of 220 students using structure and sort them in alphabetical order with respect to their name and display them.
  6. WAP to read two number and add them using pointer.
  7. WAP to input two numbers and swap the two number using call by reference method.
  8. WAP to create data file name student.txt and write name, roll no, section and marks of a student to this file and display the contents of the data file.
  9. WAP to write and read a name, employee id and salary of the ‘n’ employees from to data file using structure.
  10. WAP to write and read a name, employee id and salary of the employees from to data file using structure also continue ‘y’ to input the record as long as the user press.
  11. WAP to append the name and marks of a 10 students to a student.txt file and display all the records.
  12. WAP to demonstrate to remove and rename functions.
  13. WAP to store name and roll no of ‘n’ number of students using structure. Ask roll no from a user to delete that record and display it in proper format.
  14. WAP in JavaScript to calculate factorial of a number using function.
  15. WAP in JavaScript to calculate the area of rectangle using function.
  16. WAP in JavaScript using any four event handling objects.
  17. WAP in JavaScript using switch case statement to calculate the area of rectangle, area of circle, area of cube.
  18. WAP to connect database/MySQL using PHP.

Comments

Popular posts from this blog

Question Collection-11

Important Questions for XII