St.
Mary’s Secondary School
Jawalakhel, Nepal
A Lab Report on
C Program
Submitted in Partial Fulfillment of Requirements for
+2 Higher Secondary Level
Under Curriculum Development Center
Submitted by:
Chahana Singh Mahat
11”C”
Roll No: 9
Under the supervision of
Dr. Rupendra Man Rajkarnikar
Department of Computer Science
Date: 08/01/2026
1
Acknowledgement
This lab report would not have been possible without the kind support and help of my friends
and family. I would like to extend my sincere thanks to all of them.
I am highly indebted to my teacher Dr. Rupendra Man Rajkarnikar for his guidance and constant
supervision as well as for providing necessary information regarding the project.
Chahana Singh Mahat
2
Declaration
I hereby declare that the project work entitled “C LANGUAGE” submitted to St. Mary’s School is a
record of an original work done by me under the guidance and supervision of Dr. Rupendra Man
Rajkarnikar, department of computer science and this project work is submitted in the partial
fulfillment of the requirements for class 11 Computer Science.
----------------
Chahana Singh Mahat
11 ‘C’
9
3
Certification
This is to certify that Chahana Singh Mahat student of class 11C has successfully completed his
project work on “C LANGUAGE” under the guidance and supervision of Dr. Rupendra Man
Rajkarnikar, Department of Computer Science, St. Mary’s School, Jawalakhel.
…………………………………………………
Dr. Rupendra Man Rajkarnikar
4
Table of Contents
WAP in C to print Odd or Even………..6
WAP in C to print Positive, Negative or Neutral……….7
WAP in C to print the greatest among three numbers……..8
WAP in C to print the smallest among three numbers……..9
WAP in C to display the sum of 1 to 500………10
WAP in C to display the sum of multidigit number…….11
WAP in C to display the reverse without library function…………….12
WAP in C to display the reverse with library function………………..13
WAP in C to display palindrome without library function………14
WAP in C to display palindrome with library function……….15
WAP in C to display Fibonacci series…………16
WAP in C to display Factorial of any number……..17
5
WAP in C to display odd or even number
#include<stdio.h>
void main( )
{
int num;
printf("Enter Any number ");
scanf("%d",&num);
if(num % 2 ==0)
{
printf("%d is Even Number",num);
}
else
printf("%d is ODD number",num);
}
Output:
6
WAP in C to display positive, negative or neutral number
#include<stdio.h>
void main()
{
int n;
printf ("enter any number");
scanf ("%d",&n);
if (n>0)
printf("%d is positive", n);
else if (n<0)
printf("%d is negative",n);
else
printf("%d is neutral",n);
}
Output:
7
WAP in C to display the greatest number among three
#include <stdio.h>
void main()
{
int a,b,c;
printf("enter any three numbers as a,b,c");
scanf("%d %d %d",&a,&b,&c);
if (a>b && a>c)
printf("%d is the greatest number, a");
else if (b>a && b>c)
printf ("%d is the greatest number, b");
else
printf("%d is the greatest number, c");
Output:
8
WAP in C to display the smallest number among three
#include <stdio.h>
void main()
{
int a,b,c;
printf("enter any three numbers as a,b,c");
scanf("%d %d %d",&a,&b,&c);
if (a<b && a<c)
printf("%d is the smallest number, a");
else if (b<a && b<c)
printf ("%d is the smallest number, b");
else
printf("%d is the smallest number, c");
}
Output:
9
WAP in C to display the sum of 1 to 500 numbers
#include <stdio.h>
void main()
{
int i,s=0;
for (i =1; i<=500; i++)
{
s= s+i;
}
printf("sum is %d",s);
}
Output:
10
WAP in C to display the sum of any multidigit number
#include <stdio.h>
void main()
{
int n, sum = 0, remainder;
printf("enter any number:");
scanf("%d",&n);
while (n!=0)
{
remainder = n%10;
sum = sum+ remainder;
n=n/10;
}
printf("the sum of multidigit number is %d", sum);
}
Output:
11
WAP in C to display reverse (with and without library function)
Without library function:
void main()
{
int num, rev=0, remainder;
printf("enter any number");
scanf("%d",&num);
while (num!=0)
{
remainder = num%10;
rev =rev*10 + remainder;
num = num/10;
}
printf("the reverse is %d",rev);
Output:
12
With library function:
#inclide<stdio.h>
#include <string.h>
void main()
{
char a[25];
printf("enter any word");
scanf("%s",a);
strrev(a);
printf("the reversed word is %s",a);
Output:
WAP in C to display palindrome (with and without library function)
13
Without librabry function:
#include<stdio.h>
void main()
{
int num, rev=0, remainder, original;
printf("enter any no.");
scanf("%d",&num);
original = num;
while(num!=0)
{
remainder = num%10;
rev = rev*10 + remainder;
num = num/10;
}
if(rev==original)
printf("palindrome");
else
printf("not palindrome");
}
Output:
With library function:
14
#include<stdio.h>
#include <string.h>
void main()
{
char a[25], b[25];
printf("enter any word");
scanf("%s",a);
strcpy(b,a);
strrev(a);
if(strcmp(a,b)==0)
printf("paindrome");
else
printf("not palindrome");
}
Output:
WAP in C to display Fibonacci series
15
#include <stdio.h>
void main()
{
int a=1, b=1, c,i;
for (i=1; i<=20; i++)
{
printf("%d ",a);
c= a+b;
a=b;
b=c;
}
Output:
16
WAP in C to display factorial of any number
#include<stdio.h>
void main()
{
int factorial =1, n,i;
printf("enter any number");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
factorial = factorial *i;
}
printf("the factorial of number is %d",factorial);
}
Output:
17