google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C solved practical slips of F.Y.B.Sc. Computer Science

Monday, December 16, 2019

C solved practical slips of F.Y.B.Sc. Computer Science

C solved practical slips of F.Y.B.Sc. Computer Science:

Program 1:
Title:To demonstrate the use of data types and simple operators

#include
#include
void main()
{
float fahr,cel=0,kel=0;
clrscr();
printf(“\n Enter temperature in Fahrenheit:”);
scanf(“%f”,&fahr);
cel=((5.0/9)*(fahr-32));
kel=cel+273.15;
printf(“\n Temperature in 1 elsius is %0.2f”,cel);
printf(“\n Temperature in kelvin is %0.2f”,kel);
getch();
}

Output:
Enter the temperature in Fahrenheit:50
Temperature in Celsius is 10.00
Temperature in Kelvin is 283.15



Program no: 2
Title:To demonstrate the use of if, if-else statements

#include
#include
void main()
{
int year;
clrscr();
printf(“\n Enter the year:”);
scanf(“%d”,&year);
if(year%4==0 && year%10!=0 || year%400==0)
printf(“\n %d is leap year”,year);
else
printf(“\n %d is not leap year”,year);
getch();
}

Output:
Enter the year:1994
1994 is not leap year
Enter the year:2004
2004 is leap year




Program no: 3
Title:To demonstrate the use of switch case

#include
#include
void main()
{
int n;
float rad;
clrscr();
printf(“\n Enter the radius:”);
scanf(“%f”,&rad);
printf(“\n Enter your choice:”);
printf(“\n 1.Area of circle”);
printf(“\n 2.Circumference of circle \n 3.Volume of circle:\t”);
scanf(“%d”,&n);
switch(n)
{
case 1:printf(“\n Area of circle=%0.2f”,3.14*rad*rad);
break;
case 2:printf(“\n Circumference of circle=%02f”,2*3.14*rad);
break;
case 3:printf(“\n Volume of of circle=%0.2f”,1.334*3.14*rad*rad*rad);
break;
default:printf(“Invalid choice”);
}
getch();
}

Output:
Enter radius:2
Enter your choice:
1. Area of circle
2. Circumference of circle
3. Volume of circle
Entre your choice:1
1. Area of circle: 12.56


Program no: 4
Title:To demonstrate the use ofloops


#include
#include
void main()
{
int n,a=1,b=1,c;
clrscr();
printf(“\n Enter the last number:”);
scanf(“%d”,&n);
printf(“\n Fibnoacci series is:\t%d\t%d”,a,b);
do
{
c=a+b;
printf(“\t%d”,c);
a=b; b=c;
}while(c<=n);
getch();
}

Output:
Enter the last number:50
Fibnoacci series is:1 1 2 3 5 8 13 21 34 55



Program no: 5
Title:To demonstrate the use of looping structures

#include
#include
void main()
{
int a,b,c,sum=0,x;
clrscr();
printf(“\n The Armstrong number between the range 1 & 500 are:\n”);
for(x=1;x<=500;x++)
{
a=x; sum=0;
do
{
b=a%10;
sum+=(b*b*b);
a=a/10;
}while(a!=0);
if(sum==x)
printf(“\t%d”,x);
}
getch();
}

Output:
The Armstrong number between the range 1 & 500 are:
1 153 370 371 407

No comments:

Post a Comment

शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...