C-LANGUAGE
PROJECT FILE
INDEXPARTICULAR T.SIGN
1WAP TO ADD TWO VARIABLES
2WAP TO PRINT STARS ON SCREEN
3WAP TO FIND THE FACTORIAL OF THE NUMBER
4WAP TO FIND IF NUMBER=10 THEN GOOD ELSE BAD
5WAP TO PRINT FABBONIC SERIES FROM 1 TO 55
6WAP TO PRINT ODD NUMBERS FROM 1 TO 20
7WAP TO FIND THAT NUMBER IS PRIME OR NOT (7,11,13,17,19 ETC.)
8WAP TO FIND THAT NUMBER IS PALINDROME OR NOT (121=121)
9WAP TO CONVERT CELSIUS TO FAHRENHEIT
10WAP TO FIND OUT TOTAL MARKS & PERCENTAGE OF THREE SUBJECTS
.11WAP TO FIND OUT BIGGER NUMBER (IF-ELSE)
12WAP TO DISPLAY 5 STUDENTS MARKS AND THEIR DIVISION
13WAP TO SHOW IF-ELSE
14WAP TO CALCULATE SI FOR THREE SETS OF VALUES.
15WAP TO SUM, SUBTRACT, MULTIPLY & DIVISION OF TWO NUMBERS (5 VARIABLES)
16WAP TO FIND OUT A NUMBER IS EVEN OR ODD
17WAP TO DISPLAY AVERAGE OF TWO NUMBERS
P.1WAP TO ADD TWO VARIABLES
#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b,c;
clrscr();
printf ("Enter A: ");
scanf ("%d",&a);
printf ("Enter B: ");
scanf ("%d",&b);
c=a+b;
printf ("\nSum is %d",c);
getch ();
}
Output
P.2WAP TO PRINT STARS ON SCREEN
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j;
clrscr();
for (j=1;j<4;j++)
{
for (i=1;i<=5;i++)
{
printf ("*");
}
printf ("\n");
}
getch ();
}
P.3WAP TO FIND THE FACTORIAL OF THE NUMBER
#include<stdio.h>
#include<conio.h>
void main ()
{
int fact=1,no;
clrscr();
printf ("Enter any number: ");
scanf ("%d",&no);
do
{
fact=fact*no;
no--;
}
while (no>0);
printf ("\nFactorial is %d",fact);
getch ();
}
P.4WAP TO FIND IF NUMBER=10 THEN GOOD ELSE BAD
#include<stdio.h>
#include<conio.h>
void main ()
{
int a;
clrscr ();
printf ("Enter any Number: ");
scanf ("%d",&a);
if (a==50)
goto g;
else
goto b;
g:
printf ("Good");
goto end;
b:
printf ("Bad");
goto end;
end:
getch ();
}
P.5WAP TO PRINT FABBONIC SERIES FROM 1 TO 55
#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b,c;
clrscr ();
a=0;b=1;c=1;
printf ("%d\n%d",a,b);
while (c<55)
{
c=a+b;
printf ("\n%d",c);
a=b;
b=c;
}
getch ();
}
P.6WAP TO PRINT ODD NUMBERS FROM 1 TO 20
#include<stdio.h>
#include<conio.h>
void main ()
{
int a;
clrscr ();
a=1;
while (a<=20)
{
if (a%2==1)
printf ("\n%d",a);
a++;
}
getch ();
}
P.7WAP TO FIND THAT NUMBER IS PRIME OR NOT (7,11,13,17,19 ETC.)
#include<stdio.h>
#include<conio.h>
void main ()
{
int no,i=2;
clrscr ();
printf ("Enter Number: ");
scanf ("%d",&no);
while (i<=no)
{
if (no%i==0)
break;
i++;
}
if (i==no)
printf ("Number is Prime");
else
printf ("Number is not Prime");
getch ();
}
P.8WAP TO FIND THAT NUMBER IS PALINDROME OR NOT (121=121)
#include<stdio.h>
#include<conio.h>
void main ()
{
int no,r,res,temp=0;
clrscr ();
printf ("Enter Number: ");
scanf ("%d",&no);
r=res=0;
temp=no;
while (no>0)
{
r=no%10;
no=no/10;
res=(res*10)+r;
}
if (temp==res)
printf("Number is Palindrome");
else
printf("Number is not Palindrome");
getch ();
}
P.9WAP TO CONVERT CELSIUS TO FAHRENHEIT
#include<stdio.h>
#include<conio.h>
void main ()
{
float c,f;
clrscr ();
printf ("Enter the value of Celsius: ");
scanf ("%f",&c);
f=(float) 9/5*c+32;
printf ("\nFahrenheit is %.2f",f);
getch ();
}
P.10WAP TO FIND OUT TOTAL MARKS & PERCENTAGE OF THREE SUBJECTS
#include<stdio.h>
#include<conio.h>
void main ()
{
int m1,m2,m3;
float tm,per;
clrscr ();
printf ("Enter M1: ");
scanf ("%d",&m1);
printf ("Enter M2: ");
scanf ("%d",&m2);
printf ("Enter M3: ");
scanf ("%d",&m3);
tm=m1+m2+m3;
per=(tm/300*100);
printf ("\nTotal Marks are %.2f",tm);
printf ("\nPercentage is %.2f",per);
getch ();
}
P.11WAP TO FIND OUT BIGGER NUMBER (IF-ELSE)
#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b;
clrscr ();
printf ("Enter the value of A: ");
scanf("%d",&a);
printf ("Enter the value of B: ");
scanf ("%d",&b);
if (a>b)
{
printf ("A is Greater");
}
else
{
printf("B is Greater");
}
getch ();
}
P.12WAP TO DISPLAY 5 STUDENTS MARKS AND THEIR DIVISION
#include<stdio.h>
#include<conio.h>
void main(){ int m1, m2, m3, m4, m5, percent;
printf(“Enter marks in five subjects.”);scanf(“%d%d%d%d%d%d”, &m1, &m2, &m3, &m4, &m5);percent = ( m1+m2+m3+m4+m5)*100/500;if( percent >=60 )
printf(“First Division”);else{ if( percent >= 50 )
printf(“Second Division”);
else{ if( percent >= 40)
printf(“Third Division”);else
printf(“Fail”);}
}}
P.13WAP TO SHOW IF-ELSE
#include<stdio.h>
#include<conio.h>
void main(){ int i;
printf(“Enter either 1 or 2.”);scanf(“%d”, &i);if( i == 1)
printf(“You would go to heaven.”);else{ if( i == 2 )
printf(“Hell was created with you in mind.”);else
printf(“How about the earth.”);}
}
P.14WAP TO CALCULATE SI FOR THREE SETS OF VALUES.
#include<conio.h>#include<stdio.h>void main(){ int p, n, count;
float r, si;clrscr();for( count = 1; count <= 3; count ++){ printf(“ Enter values of p, n, & r.”);
scanf(“%d %d %f”, &p, &n, &r);si = p*n*r/100;printf(“ \n Simple Interest = Rs. %f”, si);
}getch();
}
P.15WAP TO SUM, SUBTRACT, MULTIPLY & DIVISION OF TWO NUMBERS (5 VARIABLES)
#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b,c,d,e,f;
clrscr();
printf ("Enter A: ");
scanf ("%d",&a);
printf ("Enter B: ");
scanf ("%d",&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf ("\nSum is : %d",c);
printf ("\nSubtraction is : %d",d);
printf ("\nMultiplication is : %d",e);
printf ("\nDivision is : %d",f);
getch ();
}
P.16WAP TO FIND OUT A NUMBER IS EVEN OR ODD
#include<stdio.h>
#include<conio.h>
int main(){
int number ;
printf("Enter a whole number\n");
scanf("%d",&number);
if(number % 2 == 0)
printf("number is even.\n");
elseprintf("number is odd.\n");
return 0;}
P.17WAP TO DISPLAY AVERAGE OF TWO NUMBERS
#include<stdio.h>
#include<conio.h>
int Average(int i);
int main(){int num;do{printf("Enter numbers.\n");scanf("%d",&num);if(num != -1)printf("The average is %d", Average(num));printf("\n");
}while(num>-1);
return 0;}
int Average(int i){static int sum = 0, count = 0;sum = sum + i;count++;return sum / count;}