0% found this document useful (0 votes)
22 views44 pages

Vaish College of Engineering

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views44 pages

Vaish College of Engineering

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 44

VAISH COLLEGE OF ENGINEERING

PRACTICAL - FILE
Name: Section: A
Roll No: Subject: C-Programming

Department:- BCA-1st Year


SUBMITTED TO:- MS. POOJA
MA’AM

SUBMITTED BY:- ANIKET

certificate

This is to certify that Aniket of section-A (BCA) has completed his


research on the project of C programming .
He has taken proper care and shown utmost sincerity in the completion
of his Project , under the guidance of Ms.Pooja Ma’am during this year
2024-2025.

Signature:
ACKNOWLEDGEMENT

I Would like to express my special thanks of gratitude to my

c-programming teacher “mr.pooja” for their able guidance and support in completing my project
which helped me in doing a lot of research and I came to know about so many new things.

I am thankful to them. Secondarily I would like to thank my parents who helped me in making
me in making this project within a limited period.

Date:

Aniket

Bca, section (a)


index
Sr. No. Topics Page No. Remarks
1. W.A.P to find factorial of
any number.
2. W.A.P to find number is
greater than 8 or not using if
else.
3. W.A.P to find character is
vowel or not using else if
ladder.
4. W.A.P to find greater between
3.no of using nested if.
5. W.A.P using while loop to

display even no. b/w 1 to 50.


6. W.A.P using do while loop to
display counting 1 to 50.
7. W.A.P using for loop to display

table of any numbe.


8. W.A.P using switch to display
days of week.
9. W.A.P to check number
number is positive or
negative .
10.
W.A.P of Fibonacci series.
11. W.A.P to display star pattern.

12. W.A.P to find location of an


element in an array.
13. W.A.P of call by value .

14. W.A.P of call by reference.


15. W.A.P of sum using pointer.

Program 1:- W.A.P to check whether the given number is positive


or negative.
#include<stdio.h>
#include<conio.h>
Void main()
{
Int a;
Printf(“enter the value of a”);
Scanf(“%d”,&a);
If(a>0)
{
Printf(“number is positive”);
}
Else
{
Printf(“number is negative”);
}
Getch();
}
Output display:-of the program to check whether the
given number is positive or negative will be show:
Program 2:- W.A.P to find number is greater than 8 or not using if
else.

#include <stdio.h>

int main() {
int number;

printf("Enter a number: ");


scanf("%d", &number);

if (number > 8) {
printf("Number is greater than 8.\n");
} else {
Printf(“number is greater than 8.\n”);
}
getch();
}

Output display:-program to check number is greater than


8 or not.
Program 3:-W.A.P to find character is vowel or not
using else if ladder.

#include <stdio.h>

int main() {
char ch;
printf("Enter a character: ");
scanf("%c", &ch);

if (ch == 'a') {
printf("Vowel\n");
} else if (ch == 'e') {
printf("Vowel\n");
} else if (ch == 'i') {
printf("Vowel\n");
} else if (ch == 'o') {
printf("Vowel\n");
} else if (ch == 'u') {
printf("Vowel\n");
} else {
printf("Not a vowel\n");
}

getch();
}
Output display:- program to check character is vowel or
not using else if ladder.
Program 4:-W.A.P to find greater between 3 no using
nested if.
#include <stdio.h>

int main() {
int num1, num2, num3;

printf("Enter three numbers: ");


scanf("%d %d %d", &num1, &num2, &num3);

if (num1 >= num2) {


if (num1 >= num3) {
printf("%d is the greatest.\n", num1);
} else {
printf("%d is the greatest.\n", num3);
}
} else {
if (num2 >= num3) {
printf("%d is the greatest.\n", num2);
} else {
printf("%d is the greatest.\n", num3);
}
}

getch();
}
Output display:- program to check greater between 3.no
using nested if
Program 5.:-W.A.P using while loop to display even no.
b/w 1 to 50.
#include <stdio.h>

int main() {
int num = 2;

printf("Even numbers between 1 and 50 are:\n");

while (num <= 50) {


printf("%d\n", num);
num += 2;
}

getch();
}
Output display:- program to display even no.b/w 1 to 50
using while loop.
Program 6:- W.A.P. using do while loop to display counting 1 to
50.

#include <stdio.h>

int main() {
int num = 1;

printf("Counting from 1 to 50:\n");

do {
printf("%d\n", num);
num++;
} while (num <= 50);

getch();

}
output display:-program to print counting 1 to 50 using
do while loop.

Program 7. W.A.P. using for loop to display table of any number.


#include <stdio.h>

int main() {
int number, i;

printf("Enter a number to display its table: ");


scanf("%d", &number);

printf("Table of %d:\n", number);


for (i = 1; i <= 10; i++) {
printf("%d x %d = %d\n", number, i, number * i);
}

getch();

}
output Screen:-program to display table
of any number using for loop.
Program 8.

W.A.P. using switch to display days of week.

#include <stdio.h>

void main()
{
int day;

printf("Enter day: ");

scanf("%d", &day);

switch (day) {
case 1:
printf("Sunday\n");
break;
case 2:
printf("Monday\n");
break;
case 3:
printf("Tuesday\n");
break;
case 4:
printf("Wednesday\n");
break;
case 5:
printf("Thursday\n");
break;

case 6:
printf("Friday\n");
break;
case 7:
printf("Saturday\n");
break;
default:
printf("Invalid day number\n");

getch();
}

output Screen:-program display days of week using


switch.
Program 9.
W.A.P. to check number number is positive or negative.

#include<stdio.h>

#include<conio.h>

void main()

{
int a;
printf("enter the value of a");
scanf("%d",&a);

if (a>0)
{
printf("Number is Positive");
}
else
{

printf("Number is Negative");

getch();

Output Screen:-program to check number number is


positive or negative.
Program 10.
W.A.P. of fibonacci series.

#include <stdio.h>

void main() {
int n, first = 0, second = 1, next, i;

printf("Enter the number of terms: ");


scanf("%d", &n);

printf("Fibonacci Series: ");

for (i = 0; i < n; i++) {


if (i <= 1)
next = i;
else {
next = first + second;
first = second;
second = next;
}
printf("%d ", next);
}

getch();
}

Output screen:-program of fibonacci series.


Program 11.

W.A.P. to display star pattern.

#include <stdio.h>

int main() {
int rows, i, j;

printf("Enter number of rows: ");


scanf("%d", &rows);

for (i = 1; i <= rows; i++) {


for (j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
getch();
}
Output Screen:- program to print star pattern.
Program 12.

W.A.P. to find location of an element in an array.

#include <stdio.h>
void main()

int a[5],i,item;

printf("enter 5 elements");

for(i=0;i<5;i++)

scanf("%d",&a[i]);

for(i=0;i<5;i++)
printf("\n%d",a[i]);

printf("\n item to be searched");

scanf("%d",&item);

for(i=0;i<5;i++)

if(item==a[i])

printf("item is in list at location %d", i);


}

getch();

}
Output Screen:- program to find location of an element in an
array.
Program 13.:- call by value program

#include <stdio.h>
#include<conio.h>

// Function prototype
void swap(int a, int b);

int main() {
int x = 20, y = 30;

printf("Before swapping, x = %d and y = %d\n", x,


y);

// Call the swap function


swap(x, y);

printf("After swapping, x = %d and y = %d\n", x,


y);

return 0;
}

// Function definition
void swap(int a, int b) {
int temp;

temp = a;
a = b;
b = temp;

printf("Inside the swap function, a = %d and b =


%d\n", a, b);
}
Output Screen:-program of call by value.
Program 14.:- call by reference

#include <stdio.h>

void swap(int *a, int *b) {


int temp = *a;
*a = *b;
*b = temp;
}

int main() {
int x = 20, y = 30;

printf("Before swapping: x = %d, y = %d\n", x, y);

// Passing the addresses of x and y


swap(&x, &y);

printf("After swapping: x = %d, y = %d\n", x, y);


return 0;
}
Output Screen:-program of call by reference.
Program 15.:- Program of sum using pointer

#include <stdio.h>
#include<conio.h>

int main() {
int num1, num2, sum;
int *ptr1, *ptr2;

printf("Enter two numbers: ");


scanf("%d %d", &num1, &num2);

ptr1 = &num1;
ptr2 = &num2;

sum = *ptr1 + *ptr2;

printf("Sum = %d\n", sum);

return 0;
}
Output Screen:- program of sum using pointer.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy