C Language_Practicals Assignment for Std 10E_final_pdf
C Language_Practicals Assignment for Std 10E_final_pdf
INTRODUCTION TO C LANGUAGE]
1) Write a program to display message using printf() function.
- File name – p1.c
Output
#include<stdio.h>
#include<conio.h>
main ()
{
printf(“WELCOME TO COMPUTER LAB”);
getch();
}
2) Write a program to display first letter of your name using printf() function.
- File name – p2.c
#include<stdio.h> Output
#include<conio.h>
main ()
{
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* ”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* * ”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* * ”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
printf(“\n\t\t\t\t\t\t\t\t\t\t* *”);
getch();
}
3) Write a program to add two numbers.
- File name – p3.c Output
#include<stdio.h>
#include<conio.h>
main ()
{
int n1,n2,n3;
printf(“ENTER FIRST NUMBER :”);
scanf(“%d”,&n1);
printf(“ENTER SECOND NUMBER :”);
scanf(“%d”,&n2);
n3=n1+n2;
printf(“ADDITION OF TWO NUMBERS ARE %d”,n3 );
getch();
}
4) Write a program to subtract two numbers.
- File name – p4.c Output
#include<stdio.h>
#include<conio.h>
main ()
{
int n1,n2,n3;
printf(“ENTER FIRST NUMBER :”);
scanf(“%d”,&n1);
printf(“ENTER SECOND NUMBER :”);
scanf(“%d”,&n2);
n3=n1-n2;
printf(“SUBTRACTION OF TWO NUMBERS ARE %d”,n3 );
getch();
}
4
13) Write a program to enter 7 subjects mark, find total and average.
- File name – p13.c Output
#include<stdio.h>
#include<conio.h>
main ()
{
int m1,m2,m3,m4,m5,m6,m7,total;
float per;
m1=70; m2=90; m3=87; m4=96; m5=88; m6=85; m7=100;
printf("\n SEVEN SUBJECTS MARK");
printf("\n MARK1=%d \n MARK2=%d \n MARK3=%d \n MARK4=%d
\n MARK5=%d \n MARK6=%d \n MARK7=%d", m1,m2,m3,m4,m5,m6,m7);
total=m1+m2+m3+m4+m5+m6+m7;
printf("\n TOTAL IS = %d",total);
per=(total/7);
printf("\n PERCENTAGE = %.2f %",per);
getch();
}
[ 11. DATA TYPES, OPERATORS AND EXPRESSION IN C LANGUAGE ]
14) Write a program to convert meter into milimeter. File name – p14.c
#include<stdio.h>
#include<conio.h> Output
else if(choice == 5)
{
printf("\nYOU HAVE CHOSEN CHOCOLATE VANILLA FLAVOR\n
THANK YOU");
}
else
{
printf("\n YOU HAVE CHOICE IS INVALID\n TRY AGAIN");
}
getch();
}
Output
8
22) Write a program to find that given number is odd or even & it is
divisible by 2 or not. File name–p22.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int no;
printf(“ENTER ANY NUMBER :”);
scanf(“%d”, &no);
if (no%2==0)
{
printf(“\n NUMBER IS EVEN”);
printf(“\n NUMBER IS DIVISIBLE BY 2”);
}
else
{
printf(“\n NUMBER IS ODD”);
printf(“\n NUMBER IS NOT DIVISIBLE BY 2”);
}
getch();
}
9
[ CHAPTER - 14. LOOP CONTROL STRUCTURES ]
24) Write a program to print ‘*’ . Using for loop. File name–p24.c
How many rows do you want : 5 *
* *
* * *
* * * *
* * * * *
#include<stdio.h>
Output
#include<conio.h>
main ()
{
int row;
int spaces = 40;
int count = 1;
int i, j;
printf("HOW MANY ROWS DO YOU WANT: ");
scanf("%d",&row);
for (i=1; i<=row; i++)
{
for (j=1; j<=spaces; j++)
#include<stdio.h> Output
#include<stdio.h> Output
#include<conio.h>
main ()
{
int number[6]={1,2,3,4,5,6};
int i;
11
for(i =0; i <= 5; i++)
printf("%d \n", number[i]);
getch();
}
29) Write C program to find Multiplication Table. File name–p29.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int mul[10][10];
int i,j,r,c;
printf("\n MULTIPLICATION TABLE\n\n");
printf(" ");
for(j=1;j<=10;j++)
printf("%4d",j);
printf("\n");
printf("---------------------------------------------\n");
for(i=0;i<10;i++)
{
r=i+1;
printf("%2d|",r);
for(j=1;j<=10;j++)
{
#include<stdio.h> Output
#include<conio.h>
max ();
main ()
{
int n1,n2;
max();
getch();
}
max()
{
12
int no1,no2;
printf("\n ENTER NUMBER1 :");
scanf("%d", &no1);
printf("\n ENTER NUMBER2 :");
scanf("%d", &no2);
if (no1 > no2)
{
printf("\n %d IS GREATER THAN %d",no1,no2);
}
else
{
printf("\n %d IS GREATER THAN %d",no2,no1);
}
getch();
}
31) Write a function cube (number) that finds cube of a given number.
File name–p31.c
#include<stdio.h> Output
#include<conio.h>
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
13