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

Monday, December 16, 2019

C program solved practical slips of F.Y.B.Sc. Computer Science Laboratory Course I & II

C program solved practical slips of F.Y.B.Sc. Computer Science Laboratory Course I & II:

Program no: 6

Title:To demonstrate the use of library functions

#include
#include
#include
void main()
{
int n,x;
float s,c,l,sqr,expo;
clrscr();
printf("\n Enter the number:");
scanf("%d",&n);
do
{
printf("\n Select any of the following operations:");
printf("\n 1.Sine");
printf("\n 2.Cosine");
printf("\n 3.Log");
printf("\n 4.Exponential");
printf("\n 5.Squareroot");
printf("\n 6.Exit\t");
scanf("%d",&x);
switch(x)
{
case 1:s=sin(n);
printf("\n Sine= %f",s);
break;
case 2:c=cos(n);
printf("\n Cosine= %f",c);
break;
case 3:l=log(n);
printf("\n Log= %f",l);
break;
case 4:expo=exp(n);
printf("\n Exponential= %f",expo);
break;
case 5:sqr=sqrt(n);
printf("\n Squareroot= %f",sqr);
break;
case 6:break;
default:printf("\n Invalid choice ");
break;
}

}while(x!=6);

getch();
}

Output:

Enter the number:4
Select any of the following operations:
1.Sine
2.Cosine
3.Log
4.Exponential
5.Squareroot
6.Exit 2

Cosine = -0.6536

Select any of the following operations:
1.Sine
2.Cosine
3.Log
4.Exponential
5.Squareroot
6.Exit



Program no: 7
Title:To demonstratethe use of functions

#include
#include
void prime();
void main()
{
clrscr();
prime();
getch();
}
void prime()
{
int num,temp=0,i,j=1,ct=0,n=0,a=1;
printf("\nEnter a number:");
scanf("%d",&num);
if(num>0)
{
for(i=2;i{
if(num%i==0)
{
printf("\n not a prime number");
temp=1;
break;
}
}
if(temp==0)
printf("\n it is a prime number");
}
while(n<10 p="">{
j=1;
ct=0;
while(j<=a)
{
if(a%j==0)
ct++;
j++;
}
if(ct==2)
printf("\n\n%d",a);
n++;
}
a++;
}
}


Output:


Enter a prime number: 5
It is a prime number
2
3
5
7
11
13
17
19
23
29


Program no: 8
Title:To demonstrate the use of one dimenstional array

#include
#include
void occur();
void main()
{
clrscr();
occur();
getch();
}
void occur()
{
int a[25],i,n,count=0,x;
printf(“\n Enter number of elements:”);
scanf(“%d”,&n);
printf(“\n Enter elements for array:\n “);
for(i=0;i<=n-1;i++)
{
scanf(“%d”,&a[i]);
}
printf(“\n Enter number to check the frequency of occurrence:”);
scanf(“%d”,&x);
for(i=0;i<=n-1;i++)
{
if(a[i]==x)
count++;
}
printf(“\n The frequency of occurrence is %d”,count);
}
Output:
Enter number of elements: 5
Enter elements for array:
2
1
3
4
5
5
The frequency of occurrence is 2



Program no: 9
Title:To demonstrate the use of two dimenstional array

#include
#include
void trans();
void main()
{
clrscr();
trans();
getch();
}
void trans()
{
int a[20][20],i,j,m,n;
printf("\n Enter the number of rows and columns:");
scanf("%d\t%d",&m,&n);
printf("\n Enter elements for matrix:\n");
for(i=0;i<=m-1;i++)
{
for(j=0;j<=n-1;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\n Transpose of matrix is:\n");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=m-1;j++)
{
printf("%d",a[j][i]);
}
printf("\n");
}
}
Output:
Enter the number of rows and columns: 3 3
Enter elements for matrix:
2
3
4
5
6
7
8
9
1
Transpose of matrix is:
2 5 8
3 6 9
4 7 1






No comments:

Post a Comment

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...