0% found this document useful (0 votes)
6 views25 pages

C-LAB

This document is a practical file for the course 'Computer Programming with C' completed by Tabish Qadri at SSM College of Engineering. It includes a certificate of completion, a table of contents listing various programming exercises, and sample codes demonstrating different C programming concepts. The exercises cover arithmetic operations, assignment operators, relational operators, and other fundamental programming tasks.

Uploaded by

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

C-LAB

This document is a practical file for the course 'Computer Programming with C' completed by Tabish Qadri at SSM College of Engineering. It includes a certificate of completion, a table of contents listing various programming exercises, and sample codes demonstrating different C programming concepts. The exercises cover arithmetic operations, assignment operators, relational operators, and other fundamental programming tasks.

Uploaded by

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

COMPUTER PROGRAMMING WITH C

Practical File

Name: TABISH QADRI

University-enroll: 24048135029

Course code: CSE20204L

SSM COLLEGE OF ENGINEERING

PARIHASPORA PATTAN, BARAMULLAH

AFFILIATED TO UNIVERSITY OF KASHMIR HAZRATBAL, SRINAGAR


COMPUTER PROGRAMMING WITH C YEAR-2025

CERTIFICATE

This is to certify TABISH QADRI a student of 2ND SEM bearing the Roll No 10084 has
successfully completed the practical work for the subject COMPUTER PROGRAMMING
WITH C as per the syllabus prescribed.
The work has been carried out in the academic session 2025 under the guidance and
supervision of Er. Syed Kaiser Mehraj

Signature of HOD Signature of Instructor


Mrs. Yasmeen Er. Syed Kaiser Mehraj
(HOD CSE) (Assistant Prof CSE)

CSE20204L 1
COMPUTER PROGRAMMING WITH C YEAR-2025

TABLE OF CONTENTS

S.
EXPERIMENT
NO.

PROGRAM TO DEMONOSTRATE THE USE OF ARITHMETIC


1
OPERATIONS.

PROGRAM TO ILLUSTRATE THE USE OF ASSIGNMENT


2
OPERATOR.

3 PROGRAM TO PRINT A SIMPLE MESSAGE.

PROGRAM TO ILLUSTRATE THE USE OF RELATIONAL


4
OPERATOR.

PROGRAM TO INTERCHANGE THE VALUES OF VARIABLE


5
WITHOUT USING THIRD VALUE.

6 GREATEST OF TWO NUMBERS.

7 SUM OF SQUARES OF INTEGERS FROM 1-n

8 WAP TO GENERATE 1ST 100 PRIME NUMBERS

9 WAP TO DO THE HCF OF TWO POSITIVE NUMBERS

10 WAP 1\1!+ 2\2!+3\3!+…………+X\X!

WAP TO FIND THE MAXIMUM AND MINIMUM


11
ELEMENT IN ARRAY

12 WAP TO SEARCH AN ELEMENT IN ARRAY

CSE20204L 2
COMPUTER PROGRAMMING WITH C YEAR-2025

WAP TO DIPLAY ASCII VALUES USING ARRAY AND


13
POINTERS

14 WAP FOR SWAPPING TWO NUMBERS USING POINTER

CSE20204L 3
COMPUTER PROGRAMMING WITH C YEAR-2025

1.PROGRAM TO DEMONSTRATE THE ARTHEMATIC OPERATOR

CODE:

#include <stdio.h>
#include <conio.h>

CSE20204L 4
COMPUTER PROGRAMMING WITH C YEAR-2025

int main() {
int a, b, c, d, e, f, g;
clrscr();
printf("\nEnter value of a: “);
scanf(“%d, &a);
printf(“\nEnter value of b: “);
scanf(“%d”, &b);
c= a+b; d= a*b; e= a-b; f= a/b; g= a%b;
printf("c=%d\n", c);
printf("d=%d\n", d);
printf("e=%d\n", e);
printf("f=%d\n", f);
printf("g=%d\n", g);
getch();
return 0;
}

OUTPUT:

CSE20204L 5
COMPUTER PROGRAMMING WITH C YEAR-2025

2. PROGRAM TO ILLUSTRATE THE USE OF ASSIGNMENT OPERATOR

CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int x;
int x=17;
x+=9;
printf("%d",x);
getch();
return 0;
}

OUTPUT:

CSE20204L 6
COMPUTER PROGRAMMING WITH C YEAR-2025

3. PROGRAM TO PRINT A SIMPLE MESSAGE

CODE:

#include<stdio.h>

#include<conio.h>

intmain()

printf("welcome to C programming world \n");

printf("TabishQadri");

getch();

return 0;

OUTPUT:

CSE20204L 7
COMPUTER PROGRAMMING WITH C YEAR-2025

4. PROGRAM TO ILLUSTRATE THE USE OF RELATIONAL OPERATOR

CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
printf(“enter two numbers”);
scanf (%d%d, &a,&b);
printf(“\na>b is %d”,a>b);
printf(“\na<b is %d”,a<b);
getch();
return 0;
}

OUTPUT:

5. PROGRAM TO INTERCHANGE THE VALUES OF VARIABLE WITHOUT USING


THIRD VALUE.

CSE20204L 8
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:

#include <stdio.h>
#include<conio.h>
Int main()
{
int x,y;
x= 5, y = 7;
x = x + y;
y = x - y;
x = x - y;
printf(“x= %d\n y = %d", x,y);
getch();
return O;
}

OUTPUT:

6. GREATEST OF TWO NUMBERS

CSE20204L 9
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s;
printf("enter value of A \n");
scanf(“%d”, &a);
printf("enter value of B \n");
scanf("%d", &b);
s= (a>b)? a:b;
printf(“the greatest of two numbers is %d”, s);
getch();
return 0;
}

OUTPUT:

7.SUM OF SQUARES OF INTEGERS FROM 1-n

CSE20204L 10
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:
#include <stdio.h>
#include <conio.h>
int main() {
int n, i, sum = 0;
printf("tabish enter a number : ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
sum += i * i;
}
printf("sum of squares from 1 to %d is: %d\n", n, sum);
getch();
return 0;
}

8.WAP TO GENERATE 1ST 100 PRIME NUMBERS

CSE20204L 11
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:
#include <stdio.h>
#include <conio.h>
int main()
{
int i,j, prime;
printf("Prime numbers between 1 and 100 : \n");
for ( i=2 ; i <=100 ; i++)
{
prime = 1;
for (j = 2; j <= 2; j++)
{
if (i %j == 0)
{
prime = 0;
break;
}
}
if (prime)
{
printf ("%d", i);
}
}
printf(" \n");
getch();
return 0;
}

CSE20204L 12
COMPUTER PROGRAMMING WITH C YEAR-2025

9.WAP TO DO THE HCF OF TWO POSITIVE NUMBERS

CSE20204L 13
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:
#include <stdio.h>
#include <conio.h>
int main() {
int a, b, temp;
printf("Tabish enter two positive integers: ");
scanf("%d %d", &a, &b)
while (b != 0)
{
temp = b;
b = a % b;
a = temp;
}
printf("HCF is: %d\n", a);
getch();
return 0;
}

10. WAP 1\1!+ 2\2!+3\3!+………….+x\x!

CSE20204L 14
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:
#include<stdio.h>
#include<conio.h>
long long factorial(int n)
{
long long fact=1;
int i;
for(i=1;i<=n;i++){
fact=i;
}
return fact:
}
int main()
{
int y, i:
double sum=0.0;
clrscr();
printf("Tabish enter the value of y:"):
scanf("%d",&y);
for(i=1;i<=y; i++){
sum+=(double)i/factorial(i);
}
printf("sum of series is : %.6lf\n", sum);
getch();
return 0;
}

CSE20204L 15
COMPUTER PROGRAMMING WITH C YEAR-2025

11.WAP TO FIND MAXIMUM AND MINIMUM ELEMENT IN ARRAY

CSE20204L 16
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:
#include <stdio.h>
int main() {
int arr[5], i, max, min;
printf("Enter 5 elements:\n");
for(i = 0; i < 5; i++)
scanf("%d", &arr[i]);max = min = arr[0];
for(i = 1; i < 5; i++)
{
if(arr[i] > max) max = arr[i];
if(arr[i] < min) min = arr[i];
}
printf("Max = %d\nMin = %d\n", max, min);
return 0;
}

12. WAP TO SEARCH AN ELEMENT IN ARRAY

CSE20204L 17
COMPUTER PROGRAMMING WITH C YEAR-2025

CODE:

#include <stdio.h>
int main() {
int arr[5], i, key, found = 0;
printf("Enter 5 elements:\n");
for(i = 0; i < 5; i++)
scanf("%d", &arr[i]);
printf("Enter element to search: ");
scanf("%d", &key);
for(i = 0; i < 5; i++) {
if(arr[i] == key) {
found = 1;
break;
}
}
if(found)
printf("Element found at index %d\n", i);
else
printf("Element not found\n");
return 0;
}

OUTPUT:

CSE20204L 18
COMPUTER PROGRAMMING WITH C YEAR-2025

13. WAP TO DIPLAY ASCII VALUES USING ARRAY AND POINTERS

CODE:
#include <stdio.h>

CSE20204L 19
COMPUTER PROGRAMMING WITH C YEAR-2025

#include<conio.h.
int main() {
char str[100];
char *ptr;
int i;
printf("Enter a string: ");
gets(str);
ptr = str;
printf("\nCharacter\tASCII Value\n");
printf("--------------------------\n");
while (*ptr != '\0') {
printf(" %c\t\t %d\n", *ptr, *ptr);
ptr++;
}
getch();
return 0;
}
OUTPUT:

14. WAP FOR SWAPPING TWO NUMBERS USING POINTER

CODE:
#include <stdio.h>

CSE20204L 20
COMPUTER PROGRAMMING WITH C YEAR-2025

#include<conio.h>
void swap(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int x, y;
printf("Enter two numbers: ");
scanf("%d %d", &x, &y);
printf("\nBefore swapping:\n");
printf("x = %d, y = %d\n", x, y);swap(&x, &y);
printf("\nAfter swapping:\n");
printf("x = %d, y = %d\n", x, y);
getch();
return 0;
}
OUTPUT:

15.WAP TO FIND THE POWER OF A NUMBER USING RECURSION

CODE:
#include <stdio.h>

CSE20204L 21
COMPUTER PROGRAMMING WITH C YEAR-2025

#include <conio.h>
int power(int base, int exp) {
if (exp == 0)
return 1;
else
return base * power(base, exp - 1);
}
void main() {
int base, exp;
clrscr();
printf("Enter base and exponent: ");
scanf("%d %d", &base, &exp);
printf("%d ^ %d = %d", base, exp, power(base, exp));
getch();
}

16.WAP TO REVERSE A NUMBER USING RECURRSION

CODE:
#include<stdio.h>

CSE20204L 22
COMPUTER PROGRAMMING WITH C YEAR-2025

#include<conio.h>
int reverse(int n, int rev) {
if (n == 0)
return rev;
else
return reverse(n / 10, rev * 10 + (n % 10));
}
void main() {
int num, rev;
clrscr();
printf("Enter a number: ");
scanf("%d", &num);
rev = reverse(num, 0);
printf("Reversed number: %d", rev);
getch();
}
OUTPUT:

CSE20204L 23
COMPUTER PROGRAMMING WITH C YEAR-2025

CSE20204L 24

You might also like