Pic practical?
Pic practical?
1*/
/* Implement C programs to read two numbers and display these two numbers*/
#include<stdio.h>
#include<conio.h>
void main()
int a,b;
clrscr();
getch();
/* Implement C programs using Constants and Variables (Program to find area and volume of sphere) */
#include <stdio.h>
#include <conio.h>
void main()
float r,area,vol;
clrscr();
scanf("%f",&r);
area=4*3.14*r*r;
vol=(4*3.14*r*r*r)/3;
getch();
/* Implement C programs using Constants and Variables (Program for Gross Salary) */
#include<stdio.h>
#include<conio.h>
void main()
int basic;
float da,hra,gs;
clrscr();
scanf("%d",&basic);
printf("Dearness Allonce=%f",da);
gs=basic+da+hra;
getch();
/* Implement C programs using Constants and Variables (Program for Percentage Marks) */
#include<stdio.h>
#include<conio.h>
void main()
int m1,m2,m3,m4,m5;
float sum,per;
clrscr();
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
sum=m1+m2+m3+m4+m5;
per=(sum/500)*100;
getch();
#include <stdio.h>
#include <conio.h>
void main()
int C;
float F;
clrscr();
getch();
#include <stdio.h>
#include <conio.h>
void main()
int F;
float C;
clrscr();
scanf("%d",&F);
getch();
/*Output:
*/
7 /*Practical No. 3.3 */
#include <stdio.h>
#include <conio.h>
void main()
float l,b,area,perimeter;
clrscr();
scanf("%f",&l);
scanf("%f",&b);
printf("Area= %f",area);
printf("\nPerimeter= %f",perimeter);
getch();
/*Output:
Area= 120.000000
Perimeter= 44.000000
*/
8 /*Practical No. 4
#include <stdio.h>
#include <conio.h>
void main()
int no1,no2;
float div;
char ch;
clrscr();
scanf("%c",&ch);
scanf("%d %d",&no1,&no2);
printf("Division= %f",div);
getch();
/*Output:
*/
9 /* Practical No-5
#include<stdio.h>
#include<conio.h>
void main()
int roll;
float p;
clrscr();
scanf("%d", &roll);
scanf("%f", &p);
//scanf("%s",&fn); */
printf("\n*******************************");
printf("\n_______________________________");
printf("\n*******************************");
getchar();
10 /* Practical No.6.1
void main()
printf("Input the values for Number1 and Number2 : "); // Prompt the user to input values for
Number1 and Number2.
scanf("%d %d", &n1, &n2); // Read and store the user's input in 'n1' and 'n2'.
printf("Number1 and Number2 are equal\n"); // Print a message if Number1 and Number2 are
equal.
else
printf("Number1 and Number2 are not equal\n"); // Print a message if Number1 and Number2 are
not equal.
getch();
/*Output */
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
Else
getch();
/*Output:
Enter 2 integers: 12 56
Largest number is 56
12 /* Practical No.7.1
#include <stdio.h>
int main()
int num;
if(num % 2 == 0)
else
return 0;
/*Output */
Enter an integer: -7
-7 is odd.
13 /* Practical No.7.2
#include<stdio.h>void main()
{ int a,b,c; int big; printf("Enter any there numbers:"); scanf("%d%d%d",&a,&b,&c); if(a>b && a>c)
big = a; else if(b>c) big = b; else big = c;
printf("Largest number is: %d",big); return 0;}Sample output:Enter any there numbers: 13 25 6Largest
number is: 25
14 /* Practical No.10
#include<stdio.h>
main( )
int a, b, c, d, e, per;
per = (a + b + c + d) / 4;
if(per>=75)
printf(“\n Distinction”);
else
else
printf(“Second class);
else
printf(“\n Fail”);
15 /*Practical No.11
Title: Program to print English Calendar months as per given number (eg: If input is 4 then print “April”)
using Switch statement
#include<stdio.h>
#include<conio.h>
void main()
int no;
clrscr();
scanf("%d", &no);
switch(no)
case 1: printf("JANUARY");
break;
case 2: printf("FEBRUARY");
break;
case 3: printf("MARCH");
break;
case 4: printf("APRIL");
break;
case 5: printf("MAY");
break;
case 6: printf("JUNE");
break;
case 7: printf("JULY");
break;
case 8: printf("AUGUST");
break;
case 9: printf("SEPTEMBER");
break;
break;
break;
break;
getch();
/*Output:
Reason: MARCH
*/
16 /* Practical No.12
#include<stdio.h>
#include<conio.h>
void main()
{ int no;
clrscr();
scanf("%d",&no);
switch(no)
break;
break;
break;
break;
break;
break;
break;
/* Output:
Day: Wednesday
#include <stdio.h>
#include <conio.h>
void main()
int no,digit,sum;
clrscr();
scanf("%d",&no);
sum=0;
while(no!=0)
printf("Sum of digits=%d",sum);
getch();
/*Output:
*/
#include <stdio.h>
#include <conio.h>
void main()
int no,i,mult;
clrscr();
for(no=1;no<=5;++no)
for(i=1;i<=10;++i)
printf("%2d ",mult);
printf("\n\n");
getch();
/*Output:
Multiplication Tables:
Multiplication Table of 1
1 2 3 4 5 6 7 8 9 10
Multiplication Table of 2
2 4 6 8 10 12 14 16 18 20
Multiplication Table of 3
3 6 9 12 15 18 21 24 27 30
Multiplication Table of 4
4 8 12 16 20 24 28 32 36 40
Multiplication Table of 5
5 10 15 20 25 30 35 40 45 50
*/
#include <stdio.h>
#include <conio.h>
void main()
{ int i, j, rows;
scanf("%d", &rows);
printf("* ");
} printf("\n");
}getch(); }
/*Output:
**
***
****
*****
20 /*Practical No: 16.1
#include<stdio.h>
int main()
for(i=0;i<5;i++)
scanf("%d",&arr[i]);
for(i=0;i<5;i++)
sum=sum+arr[i];
return 0;
}
21 /*Practical No: 16.2
#include <stdio.h>
void main()
int i, j, a, n, number[30];
scanf("%d", &n);
scanf("%d", &number[i]);
a = number[i];
number[i] = number[j];
number[j] = a;
printf("%d\n", number[i]);
}
22 /*Practical No: 17
#include<stdio.h>
#include<conio.h>
void main()
int A[3][3],B[3][3],C[3][3], i, j;
clrscr();
for(i=0;i<3;++i)
{ for(j=0;j<3;++j)
{ scanf("%d",&A[i][j]);
}}
for(i=0;i<3;++i)
{ for(j=0;j<3;++j)
{ scanf("%d",&B[i][j]);
}}
/*Matrix Addition*/
for(i=0;i<3;++i)
for(j=0;j<3;++j)
C[i][j]=A[i][j]+B[i][j];
}}
printf("\nResultant matrix:\n");
for(i=0;i<3;++i)
for(j=0;j<3;++j)
printf("%2d ",C[i][j]);
} printf("\n");
} getch();
/*Output:
123456789
14 31 21 51 61 71 13 3 4
Resultant matrix:
15 33 24
55 66 77
20 11 13 */
23 /*Practical No.18.1
#include <stdio.h>
int main() {
int i;
return 0;
/* Output: */
#include <stdio.h>
#include <conio.h>
void main()
char str[60];
int leng, g;
// This will find the length of your string with the help of strlen() function of the string.h header file
leng = strlen(mystrg);
// iterate through each and every character of the string for printing it backward or reverse direction
return 0;
Output
25 /* Practical No.20
#include<stdio.h>
#include<conio.h>
struct Employee
char name[30];
int id;
int salary;
};
int main()
//number of employees
int i;
//array to store structure values of all employees
clrscr();
//Name
printf("Name: ");
scanf("%s",emp[i].name);
//ID
printf("Id: ");
scanf("%d",&emp[i].id);
//Salary
printf("Salary: ");
scanf("%d",&emp[i].salary);
printf("\n");
printf("%s \n",emp[i].name);
printf("%d \n",emp[i].id);
printf("\n");
getch();
return 0;
26 Practical No. 21
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
int ch;
clrscr();
gets (str1);
if ( ch == 0) /*check if palindrome */
else
}
getch();
/* Output:-
*/
27 /*Practical No.22.1
#include <stdio.h>
#include <conio.h>
{ long fact;
if(no == 1)
{ return(1); }
else
fact=no*factorial(no-1);
return(fact);
}}
/*Main program*/
void main()
{ int num;
long f;
clrscr();
scanf("%d",&num);
f=factorial(num);
getch();
28 /*Practical No.22.2
#include <stdio.h>
#include <conio.h>
int R, N, D;
N=no1;
D=no2;
N=no2;
D=no1;
R=N % D;
while(R != 0)
N=D;
D=R;
R=N % D;
return (D);
/*Main program*/
void main()
int num1,num2,g;
clrscr();
scanf("%d %d",&num1,&num2);
g=gcd(num1,num2);
getch();
/*Output
GCD of 75 and 25 = 25
GCD of 75 and 25 = 25
GCD of 50 and 8 = 2 */
29/*Practical No.24 Title: Program to print values of variables and their addresses */
#include <stdio.h>
#include <conio.h>
void main()
int x,y;
clrscr();
scanf("%d %d",&x,&y);
getch();
return(0);
/*Output
*/
30/*Practical No.25
Title: Implement a ‘C’ Program to perform arithmetic operations using pointer. */
#include<stdio.h>
int main()
int number;
//pointer to int
int *p,*p1,*p2;
clrscr();
p=&number;
p1=p+3;
p2=p-3;
getch();
Output
Address of p variable is
65524
#include <stdio.h>
#include <conio.h>
void main()
int no1,no2,result;
clrscr();
printf("Enter two integers: ");
scanf("%d %d",&no1,&no2);
printf("Sum = %d”,result);
printf("\nDifference = %d”,result);
printf("\nProduct = %d”,result);
printf("\nDivision = %d”,result);
getch();
32
#include <stdio.h>
int main()
int num;
scanf("%d", &num);
if(num % 2 == 0)
else
return 0;
}
/*Output */
Enter an integer: -7
-7 is odd.
33
#include <stdio.h>
#include <conio.h>
int main()
clrscr();
printf("Equilateral triangle.");
printf("Isosceles triangle.");
else
{
printf("Scalene triangle.");
getch();
return 0;
/*Output:
Scalene triangle.
Isosceles triangle.
Equilateral triangle.
*/
34
/* Logical Operator
#include<stdio.h>
#include<conio.h>
#include <ctype.h>
void main()
char ch1,ch2;
clrscr();
scanf("%c",&ch1);
printf("%c is a vowel",ch1);
else
getch();
/*
Output:-
Enter a letter: K
K is not a vowel
Enter a letter: u
u is a vowel
35
/*
#include<stdio.h>
main( )
int num;
printf(“Enter a number:”);
scanf(“%d”, &num);
/*Output*/
Enter a number: 7
Enter a number: 15
36
/*
#include<stdio.h>
main( )
{ int y;
if(y % 4 == 0)
else
else
if(y % 4 ==0)
}
else
/* Output: */
37
#include<stdio.h>
#include <conio.h>
void main()
int score;
clrscr();
scanf("%d",&score);
switch( score / 10 )
case 10:
case 9:
printf("Grade: A+\n");
break;
case 8:
printf("Grade: A\n");
break;
break;
case 6:
printf("Grade: B\n");
break;
case 5:
printf("Grade: C+\n");
break;
case 4:
printf("Grade: C\n");
break;
default:
printf("Grade: Fail\n");
break;
getch();
/*Output:
Grade: B
Grade: A+ */
38
/*for loop
#include <stdio.h>
#include <conio.h>
void main()
int i;
for(i=1;i<=100;i++)
printf(“%d\t”,i);
getch();
39
#include <stdio.h>
#include <conio.h>
void main()
struct distance{
int km;
int m;
clrscr();
getch();
/*Output
40
#include<stdio.h>
#include<conio.h>
#include <string.h>
void main()
char str1[25],str2[25],str3[50];
clrscr();
gets(str1);
gets(str2);
else
str3);
getch();
/*Output:
String-3: Nashikroad
41
#include<stdio.h>
#include<conio.h>
#include <math.h>
void main()
{
int num;
clrscr();
scanf("%f",&no);
getch();
/*Output:
*/
42
#include <stdio.h>
#include <conio.h>
{ long fact;
if(no == 1)
{ return(1); }
else
fact=no*factorial(no-1);
return(fact);
}}
/*Main program*/
void main()
{ int num;
long f;
clrscr();
scanf("%d",&num);
f=factorial(num);
getch();
/* Output
Enter an integer: 6
Factorial of 6 = 720
Enter an integer: 9
Factorial of 6 = 362880 */