0% found this document useful (0 votes)
12 views

C Language_Practicals Assignment for Std 10E_final_pdf

The document contains a series of C programming exercises, including basic operations such as addition, subtraction, multiplication, and division, as well as more complex tasks like calculating area, volume, and interest. Each exercise is accompanied by the corresponding C code and expected output. The document serves as a practical guide for learning C programming concepts and syntax.

Uploaded by

rishimarco123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

C Language_Practicals Assignment for Std 10E_final_pdf

The document contains a series of C programming exercises, including basic operations such as addition, subtraction, multiplication, and division, as well as more complex tasks like calculating area, volume, and interest. Each exercise is accompanied by the corresponding C code and expected output. The document serves as a practical guide for learning C programming concepts and syntax.

Uploaded by

rishimarco123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

[CHAPTER - 10.

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();
}

5) Write a program to multiply two numbers.


- File name – p5.c Output
#include<stdio.h>
#include<conio.h>
main ()
{

C Language Practicals - Knowledge High School, Nadiad


int n1,n2,n3;
printf(“ENTER FIRST NUMBER :”);
scanf(“%d”,&n1);
printf(“ENTER SECOND NUMBER :”);
scanf(“%d”,&n2);
n3=n1*n2;
printf(“MULTIPLICATION OF TWO NUMBERS ARE %d”,n3 );
getch();
}

6) Write a program to divide of two numbers.


- File name – p6.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(“DIVISION OF TWO NUMBERS ARE %d”,n3 );
getch();
} 2
[ 11. DATA TYPES, OPERATORS AND EXPRESSION IN C LANGUAGE ]
7) Write a program to find area of a rectangle. File name – p7.c
#include<stdio.h>
#include<conio.h> Output
main ()
{ int side1, side2, area;
printf(“ENTER ONE SIDE :”);
scanf(“%d”, &side1);
printf(“ENTER SECOND SIDE :”);
scanf(“%d”,&side2);
area=side1*side2;
printf(“AREA OF RECTANGLE = %d”, area);
getch();
}
8) Write a program to find volume of a cube. File name – p8.c
#include<stdio.h> Output
#include<conio.h>
main ()
{
int h, l, b, v;
printf(“ENTER HEIGHT :”);
scanf(“%d”, &h);
printf(“ENTER LENGTH :”);

C Language Practicals - Knowledge High School, Nadiad


scanf(“%d”,&l);
printf(“ENTER BREADTH :”);
scanf(“%d”,&b);
v=h*l*b;
printf(“VOLUME OF CUBE = %d”, v);
getch();
}
9) Write a program to calculate simple interest.
- File name-p9.c
#include<stdio.h> Output
#include<conio.h>
main ()
{ float p, r, n, i, ta;
printf("PRINCIPAL AMOUNT :");
scanf("%f", &p);
printf("RATE OF INTEREST :");
scanf("%f",&r);
printf("NUMBER OF YEARS :");
scanf("%f",&n);
i=p*r*n/100;
printf("INTEREST = %f",i );
ta=p+i;
printf("\nPRINCIPAL AMOUNT AND INTEREST = %f",ta);
getch();
3
}
10) Write a program to calculate circumference of circle with radius.
- File name – p10.c
#include<stdio.h> Output
#include<conio.h>
#define F float
#define P printf
#define S scanf
#define PI 3.14
main ()
{
F r, cir;
P(“ENTER THE VALUE OF RADIUS :”);
S(“%f”, &r);
cir=2*PI*r;
P(“\n CIRCUMFERENCE OF CIRCLE WITH RADIUS %.2f IS %.2f”, r,cir);
getch();
}

11) Use of Character datatype in C program.


- File name – p11.c
#include<stdio.h> Output
#include<conio.h>

C Language Practicals - Knowledge High School, Nadiad


main ()
{
char num= '9';
printf("Num = %c",num);
printf("\nASCII value of Num = %d", num);
getch();
}

12) Find the ASCII value of ‘A’ and ‘a’.


- File name – p12.c Output
#include<stdio.h>
#include<conio.h>
main ()
{
char ch;
ch= 'A';
printf("\n Letter is %c and its ASCII value is %d", ch, ch);
ch= 'a';
printf("\n Letter is %c and its ASCII value is %d", ch, ch);
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

C Language Practicals - Knowledge High School, Nadiad


main ()
{
long int meter, milimeter;
meter=50;
milimeter=meter*1000;
printf(“\n METER = %ld and MILIMETER = %ld mm”,meter,milimeter);
getch();
}
15) Write a program to find number is positive or negative using relational
operator. File name – p15.c
#include<stdio.h>
#include<conio.h> Output
main ()
{ int no;
printf("ENTER THE NUMBER =");
scanf("%d",&no);
if(no>0)
{
printf("\n NO. IS POSITIVE");
}
else
{
printf("\n NO. IS NEGATIVE");
}
getch(); 5
}
16) Write a C program to find 10 rupees note, 5 rupees note, 2 rupees note
and 1 rupees note. File name – p16.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int rs, ten, five, b, c, two, one;
printf("PLEASE ENTER RUPEES =");
scanf("%d",&rs);
ten=rs/10;
b=rs%10;
five=b/5;
c=rs%5;
two=c/2;
one=c%2;
printf("\n YOU HAVE ENTER RUPEES = %d",rs);
printf("\n TEN RUPEES NOTE = %d", ten);
printf("\n FIVE RUPEES NOTE = %d", five);
printf("\n TWO RUPEES NOTE = %d", two);
printf("\n ONE RUPEES NOTE = %d", one);
getch();
}

C Language Practicals - Knowledge High School, Nadiad


[ CHAPTER-12 USING I / O OPERATIONS ]
17) Using gets() and getchar() function, write a C program. File name–p17.c
#include<stdio.h> Output
#include<conio.h>
main ()
{
char name [20];
char ch;
printf(“\n ENTER YOUR NAME’S FIRST LETTER :”);
ch=getche ();
printf(“\n ENTER YOUR NAME AND SURNAME :”);
gets(name);
printf(“\n YOUR NAMES FIRST LETTER IS %c AND
YOUR NAME IS %s”, ch,name);
getch();
}
18) Using gets() function write a C program. File name–p18.c
#include<stdio.h>
Output
#include<conio.h>
main ()
{ char str1 [80];
printf(“PLEASE TYPE A STRING = \n”);
gets(str1);
printf(“THE GIVEN STRING IS = %s \n”,str1);
6
getch();
}
[ CHAPTER – 13. DECISION STRUCTURES ]
19) Write a C program to find that student is pass or fail. File name–p19.c
#include<stdio.h> Output
#include<conio.h>
main ()
{
int mark;
printf(“PLEASE ENTER MARK :”);
scanf(“%d”, &mark);
if (mark >= 33)
printf(“YOU PASSED”);
else
printf(“YOU FAILED”);
getch();
}
20) Write a program to display message, user select choice and display
output, using else if ladder. File name–p20.c
#include<stdio.h>
#include<conio.h>
main ()
{

C Language Practicals - Knowledge High School, Nadiad


int choice;
printf("WHAT FLAVOUR ICE CREAM DO YOU WANT?\n\n");
printf("ENTER 1 FOR CHOCOLATE FLAVOR\n");
printf("ENTER 2 FOR VANILLA FALVOR\n");
printf("ENTER 3 FOR STRAWBERRY FLAVOR\n");
printf("ENTER 4 FOR GREEN TEA FLAVOR\n");
printf("ENTER 5 FOR CHOCOLATE VANILLA FLAVOR\n");
printf("ENTER YOUR CHOICE :=");
scanf("%d",&choice);
if (choice == 1)
{
printf("\nYOU HAVE CHOSEN CHOCOLATE FLAVOR\n THANK YOU");
}
else if (choice == 2)
{
printf("\nYOU HAVE CHOSEN FALVOR\n THANK YOU");
}
else if (choice == 3)
{
printf("\nYOU HAVE CHOSEN STRAWBERRY FLAVOR\n THANK YOU");
}
else if (choice == 4)
{
printf("\nYOU HAVE CHOSEN GREEN TEA FLAVOR\n THANK YOU");
7
}

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

C Language Practicals - Knowledge High School, Nadiad


21) Write a program to find that given year is leap year or not.
File name–p21.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int year;
printf("\n PLEASE ENTER YEAR (YYYY format) :");
scanf("%d", &year);
if (year%4 ==0)
{
printf("\n %d IS LEAP YEAR",year);
}
else
{
printf("\n %d IS NOT LEAP YEAR",year);
}
getch();
}

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();
}

C Language Practicals - Knowledge High School, Nadiad


23) Write a program, accept the age of a person. Display whether a person
is eligible to vote or not. File name–p23.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int age;
printf(“\n ENTER AGE :”);
scanf(“%d”,&age);
if (age >= 18)
{
printf(“\n YOU CAN VOTE IN ELECTION…”);
}
else
{
printf(“\n YOU CAN NOT VOTE IN ELECTION…”);
}
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++)

C Language Practicals - Knowledge High School, Nadiad


printf(" ");
for (j=1; j<=count; j++)
printf("%c", '*');
printf("\n");
spaces--;
count = count + 2;
}
getch();
}

25) Write a program to print a reverse numbers using while loop.


File name–p25.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int i;
printf("ENTER NUMBER :");
scanf("%d",&i);
while(i>=1)
{
printf("%d \n", i);
i=i-1;
}
10
getch();
}

26) Write a program to print multiplication table using for loop.


File name–p26.c
#include<stdio.h>
#include<conio.h> Output
main ()
{
int no, i;
printf(“\n ENTER ANY NUMBER :”);
scanf(“%d”, &no);
printf(“\n\t MULTIPLICATION TABLE OF %d”,no);
for(i=1; i <=10; i++)
{
printf(“\n\t%d * %d = %d”,no,i,no*i);
}
getch();
}
[ CHAPTER - 15. ARRAYS ]
27) Using single dimension array write C program. File name–p27.c

#include<stdio.h> Output

C Language Practicals - Knowledge High School, Nadiad


#include<conio.h>
main ()
{
int i;
char name [10];
printf("ENTER YOUR NAME :");
for (i=0; i< 10; i++)
scanf("%c",&name[i]);
printf("\n YOUR NAME IN ROW WISE IS : ");
for (i=0; i < 10 ; i++)
printf("%c", name[i]);
printf("YOUR NAME IN COLUMN WISE IS : \n");
for(i = 0; i < 10; i++)
printf("%c\n", name[i]);
getch();
}
28) Write C program using array print the 1 to 6 numbers. File name–p28.c

#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++)
{

C Language Practicals - Knowledge High School, Nadiad


c=j;
mul[i][j]=r*c;
printf("%4d",mul[i][j]);
}
printf("\n");
}
getch();
}

[ CHAPTER 16. FUNCTION ]


30) Write a function that finds maximum number from given two numbers.
File name–p30.c

#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>

void cube (int no);


main ()

C Language Practicals - Knowledge High School, Nadiad


{
int n;
cube(n);
getch();
}
void cube (int n)
{
printf("\n ENTER NUMBER :");
scanf("%d",&n);
printf("\n CUBE OF GIVEN NUMBER IS %d",n*n*n);
getch();
}

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy