SlideShare a Scribd company logo
MANNAR THIRUMALAI NAICKER COLLEGE
(AUTONOMOUS)
PASUMALAI, MADURAI – 625004.
DEPARTMENT OF COMPUTER SCIENCE (ARTIFICIAL
INTELLIGENCE)
PROGRAMMING in C LAB(23UAICP11)
PRACTICAL EXAMINATION
NOVEMBER 2024
MANNAR THIRUMALAI NAICKER COLLEGE (AUTONOMOUS)
MADURAI
DEPARTMENT OF COMPUTER SCIENCE (ARTIFICIAL
INTELLIGENCE)
BONAFIDE CERTIFICATE
NAME : REG_NO :
CLASS : I B. Sc (CS) AI SEMESTER : I
SUBJECT : Programming in C Lab SUB.CODE : 23UAICP11
This is to certify that this record is a bonafide work done by the above-
mentioned student. The certificate is awarded for the same.
HEAD OF THE DEPARTMENT STAFF IN-CHARGE
Submitted for Practical Examination held on _____________ at
Mannar Thirumalai Naicker College, Pasumalai, Madurai.
INTERNAL EXAMINER EXTERNAL EXAMINER
PROGRAMMING IN C LAB
CONTENTS
S.No. Date Title
Page
No.
Signature
1. ADDITION OF TWO INTEGERS
2. MULTIPLY TWO FLOATING NUMBERS
3. WRITE A CHARACTER AND STRING
4. SWAPPING NUMBERS
5. EVEN OR ODD
6. CHECK VOWEL OR CONSONANT
7. SIMPLE INTEREST CALCULATION
8. LARGEST AMONG THREE NUMBERS
9. SUM OF N NATURAL NUMBERS
10. FACTORIAL OF A NUMBER
11.
DISPLAY PRIME NUMBERS BETWEEN
TWO INTERVALS
12. SIMPLE CALCULATOR
13
SWAPPING TWO NUMBERS USING
FUNCTION
14
FACTORIAL OF N NUMBER USING
RECURSION
15
STRUCTURES FOR EMPLOYEE
INFORMATION
16 POINTERS
17 FILE OPERATIONS
1
EX. NO :1. ADDITION OF TWO INTEGERS
Aim:
To write a c program to add two integers.
Program:
#include <stdio.h>
#include<conio.h>
void main() {
int number1,number2,sum;
printf(“Enter two integers:”);
scanf("%d %d", &number1, &number2);
sum = number1 + number2;
printf("%d + %d = %d", number1, number2, sum);
getch();
}
Output:
Enter two integers: 5
7
5 + 7 = 12
Result: Thus the program has been successfully created.
2
EX.NO:2.MULTIPLY TWO FLOATING NUMBERS
Aim:
To write c program to multiply two floating numbers.
Program:
#include <stdio.h>
#include<conio.h>
void main() {
double a, b, product;
printf("Enter two numbers: ");
scanf("%lf %lf", &a, &b);
Product=a*b;
Printf(“Product=%2lf”,Product);
getch();
Output:
Enter two numbers :2.4
1.24
Product = 2.98
Result: Thus the program has been successfully created.
3
EX.NO:3.WRITE A CHARACTER AND STRING IN C
Aim:
To write a c program to read a single character, string and sentence as input.
1. Single character:
Program:
#include <stdio.h>
#include<conio.h>
void main(){
char ch;
printf(“Enter the name:”);
scanf(“%c”,&ch);
printf(“Output:%c”,ch);
getch();
}
Output:
Enter the name: Artificial Intelligence
Output:A
2. Reading a word in c
Program:
#include<stdio.h>
#include<conio.h>
void main(){
char word[100];
printf(“Enter the word:”);
scanf(“%s”,word);
4
printf(“output:%s”,word);
getch();
}
Output:
Enter the name: Artificial Intelligence
Output: Artificial Intelligence
Result: Thus the program has been successfully created.
5
EX.NO: 4. SWAPPING NUMBERS
Aim:
To write a c program to swap two numbers.
Program:
#include<stdio.h>
#include<conio.h>
void main() {
double first, second, temp;
printf("Enter first number: ");
scanf("%lf", &first);
printf("Enter second number: ");
scanf("%lf", &second);
temp = first;
first = second;
second = temp;
printf("nAfter swapping, first number = %.2lfn", first);
printf("After swapping, second number = %.2lf", second);
getch();
}
Output:
Enter first number: 1.20
Enter second number: 3.3
After swapping, first number = 3.30
After swapping, second number = 1.20
Result: Thus the program has been successfully created.
6
EX.NO: 5. EVEN OR ODD
Aim:
To write a program in c to check whether the number is even or odd.
Program:
#include <stdio.h>
#include <conio.h>
void main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
getch();
}
Output:
Enter an integer:28
28 is even.
Enter an integer:35
35 is odd.
7
EX.NO:6.TO CHECK VOWEL OR CONSONANT
Aim:
To write a program in c to check the letter as vowel or consonant.
Program:
#include <stdio.h>
#include<conio.h>
void main() {
char c;
int lowercase_vowel, uppercase_vowel;
printf("Enter an alphabet: ");
scanf("%c", &c);
lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
if (lowercase_vowel || uppercase_vowel)
printf("%c is a vowel.", c);
else
printf("%c is a consonant.", c);
getch();
}
Output:
Enter an alphabet: y
y is a consonant.
Enter an alphabet: e
e is a vowel.
Result: Thus the program has been successfully created.
8
EX.NO:7. SIMPLE INTEREST CALCULATION
Aim:
To calculate the simple interest using C program.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int P,R,T;
double SI;
printf("Enter the principle:");
scanf("%d",&P);
printf("Enter the rate:");
scanf("%d",&R);
printf("Enter the time:");
scanf("%d",&T);
SI=(P*R*T)/100;
printf("The simple interest is %d",SI);
getch();
}
Output:
Enter the Principal: 1300
Enter the Rate: 12
Enter the Time: 2
The Simple Interest is:3120.0
Result: Thus the program has been successfully created.
9
EX.NO:8. LARGEST AMONG THREE NUMBERS
Aim:
To write c program to find the maximum number out of the three.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int A,B,C;
printf("Enter the numbers A,B,and C:");
scanf("%d%d%d",&A,&B,&C);
if(A>=B&&A>=C)
printf("%d is the largest number:",A);
else if(B>=A&&B>=C)
printf("%d is the largest number:",B);
else
printf("%d is the largest number:",C);
getch();
}
Output:
Result: Thus the program has been successfully created.
10
EX .NO:9. SUM OF n NATURAL NUMBERS
Aim:
To write a c program for sum of n natural numbers .
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
Printf(“SUM OF N NATURAL NUMBERSn”);
Printf(“===========================n”);
int i,s-=0;
int n=10;
for (i=0;i<=n;i++)
{
s+=i;
}
printf("Sum= %d ",s);
getch();
}
OUTPUT:
Result: Thus the program has been successfully created.
11
EX NO:10 FACTORIAL OF A NUMBER
Aim:
To write a factorial number
Program:
#include <stdio.h>
#include <conio.h>
void main(){
int n,i;
unsigned long long fact=1;
clrscr();
printf("FACTORIAL");
printf("n---------n");
printf("Enter an integer :");
scanf("%d",&n);
if(n<0)
printf("Error!,Factorial of negative number does'nt exist");
else
for(i=1;i<=n;++i)
{
fact*=i;
}
printf("Factorial of %d=%llu",n,fact);
getch();
}
12
Output:
Result: Thus the program has been successfully created.
13
EX NO:11 DISPLAY PRIME NUMBERS BETWEEN TWO INTERVALS
Aim:
To display the prime numbers between two intervals
Program:
#include<stdio.h>
#include <conio.h>
void main()
{
clrscr();
int low ,high,i,flag;
printf("Enter two intervals :");
scanf("%d%d",&low,&high);
printf("Prime number between %d and %d are:",low,high);
while(low<high){
flag=0;
if(low<=1){
++low;
continue;
}
for(i=2;i<=low/2;++i)
{
if(low % i==0){
flag=1;
break;
}
}
14
if(flag==0)
printf("%d ",low);
++low;
}
getch();
}
Output:
Result:
Thus the program has been successfully created.
15
EX NO:12 SIMPLE CALCULATOR USING SWITCH STATEMENT
Aim:
To calculate the program using switch statement
Program:
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
char op;
double first,second;
printf("SIMPLE CALCULATOR");
printf("n------ ----------n");
printf("Enter an operator (+,-,*,/):");
scanf("%c",&op);
printf("Enter two operands:");
scanf("%lf%lf",&first,&second);
switch (op){
case'+':
printf("%1lf+%1lf=%1lf",first,second,first+second);
break;
case'-':
printf("%1lf-%1lf=%1lf",first,second,first-second);
break;
case'*':
printf("%1lf*%1lf=%1lf",first,second,first*second);
break;
16
case'/':
printf("%1lf/%1lf=%1lf",first,second,first/second);
break;
default:
printf("Error!Operator is not correct");
}
getch();
}
Output:
Result: Thus the program has been successfully created.
17
EX.NO: 13. SWAPPING TWO NUMBERS USING FUNCTION
Aim:
To write a c program to swap two numbers using function.
Program:
#include<stdio.h>
#include<conio.h>
void swap(int,int);
int main()
{
int a,b;
printf("Enter values for a and bn");
scanf("%d%d",&a,&b);
printf("nnBefore swapping: a = %d and b = %dn",a,b);
swap(a,b);
return 0;
}
void swap (int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
printf("nAfter swapping:a=%d and b=%dn",x,y);
}
Output:
Result: Thus the program has been successfully created.
18
EX NO:14 FACTORIAL OF N NUMBER USING RECURSION
Aim:
To write a c program for factorial of n numbers using function
Program:
#include<stdio.h>
long factorial(int n)
{
if (n == 0)
return 1;
else
return(n * factorial(n-1));
}
void main()
{
int number;
long fact;
printf("Enter a number: ");
scanf("%d", &number);
fact = factorial(number);
printf("Factorial of %d is %ldn", number, fact);
return 0;
}
Output:
Enter a number: 6
Factorial of 5 is: 720
Result: Thus the program has been successfully created.
19
EX NO:15 STRUCTURES FOR EMPLOYEE DETAIL
AIM:
To write a c program to print employee information using structure
Program:
#include <stdio.h>
/*structure declaration*/
struct employee{
char name[30];
int empId;
float salary;
};
int main()
{
/*declare structure variable*/
struct employee emp;
/*read employee details*/
printf("nEnter details :n");
printf("Name :"); gets(emp.name);
printf("ID :"); scanf("%d",&emp.empId);
printf("Salary :"); scanf("%f",&emp.salary);
/*print employee details*/
printf("nEntered detail is:");
printf("Name: %s" ,emp.name);
printf("Id: %d" ,emp.empId);
printf("Salary: %fn",emp.salary);
return 0;
}
20
OUTPUT:
Result: Thus the program has been successfully created.
21
EX NO:16 PROGRAM FOR POINTERS
Aim:
To write a c program for pointers
Program:
#include <stdio.h>
void geeks()
{
int var = 10;
ble
int* ptr;
ptr = &var;
printf("Value at ptr = %p n", ptr);
printf("Value at var = %d n", var);
printf("Value at *ptr = %d n", *ptr);
}
// Driver program
int main()
{
geeks();
return 0;
}
Output:
Result: Thus the program has been successfully created.
22
EX NO:17 PROGRAM FOR FILE CREATION
Aim:
To Write a program to create a file called emp.rec and store information about a person, in
terms of his name, age and salary.
Program:
#include<stdio.h>
#include <conio.h>
#include<stdlib.h>
void main()
{
FILE *fptr;
char name[20];
int age;
float salary;
fptr = fopen("emp.rec", "w");
if (fptr == NULL)
{
printf("File does not exists n");
return;
}
printf("Enter the name n");
scanf("%s", name);
fprintf(fptr, "Name = %sn", name);
printf("Enter the agen");
scanf("%d", &age);
fprintf(fptr, "Age = %dn", age);
printf("Enter the salaryn");
scanf("%f", &salary);
fprintf(fptr, "Salary = %.2fn", salary);
23
fclose(fptr);
}
Output:
Result: Thus the program has been successfully created.
Ad

More Related Content

Similar to Subject:Programming in C - Lab Programmes (20)

Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
yogini sharma
 
C programs
C programsC programs
C programs
Vikram Nandini
 
Programming in c
Programming in cProgramming in c
Programming in c
Ashutosh Srivasatava
 
C
CC
C
Mukund Trivedi
 
C program report tips
C program report tipsC program report tips
C program report tips
Harry Pott
 
C coding#1
C   coding#1C   coding#1
C coding#1
Sekhar Pisini
 
Practical File of c++.docx lab manual program question
Practical File of c++.docx lab manual program questionPractical File of c++.docx lab manual program question
Practical File of c++.docx lab manual program question
vidhimangal05
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
AMIT SINGH
 
Hargun
HargunHargun
Hargun
Mukund Trivedi
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
Md Masudur Rahman
 
Chapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxChapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docx
Shamshad
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecture
myinstalab
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
 
I PUC CS Lab_programs
I PUC CS Lab_programsI PUC CS Lab_programs
I PUC CS Lab_programs
Prof. Dr. K. Adisesha
 
Class task 4
Class task 4Class task 4
Class task 4
ARFIJAMAL123
 
Fuzail_File_C.docx
Fuzail_File_C.docxFuzail_File_C.docx
Fuzail_File_C.docx
SyedFuzail14
 
comp2
comp2comp2
comp2
franzneri
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
tristans3
 
C file
C fileC file
C file
simarsimmygrewal
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
yogini sharma
 
C program report tips
C program report tipsC program report tips
C program report tips
Harry Pott
 
Practical File of c++.docx lab manual program question
Practical File of c++.docx lab manual program questionPractical File of c++.docx lab manual program question
Practical File of c++.docx lab manual program question
vidhimangal05
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
AMIT SINGH
 
Chapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxChapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docx
Shamshad
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecture
myinstalab
 
Fuzail_File_C.docx
Fuzail_File_C.docxFuzail_File_C.docx
Fuzail_File_C.docx
SyedFuzail14
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
tristans3
 

Recently uploaded (20)

Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Adobe Media Encoder Crack FREE Download 2025
Adobe Media Encoder  Crack FREE Download 2025Adobe Media Encoder  Crack FREE Download 2025
Adobe Media Encoder Crack FREE Download 2025
zafranwaqar90
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-RuntimeReinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Natan Silnitsky
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Adobe Media Encoder Crack FREE Download 2025
Adobe Media Encoder  Crack FREE Download 2025Adobe Media Encoder  Crack FREE Download 2025
Adobe Media Encoder Crack FREE Download 2025
zafranwaqar90
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-RuntimeReinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Natan Silnitsky
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Ad

Subject:Programming in C - Lab Programmes

  • 1. MANNAR THIRUMALAI NAICKER COLLEGE (AUTONOMOUS) PASUMALAI, MADURAI – 625004. DEPARTMENT OF COMPUTER SCIENCE (ARTIFICIAL INTELLIGENCE) PROGRAMMING in C LAB(23UAICP11) PRACTICAL EXAMINATION NOVEMBER 2024
  • 2. MANNAR THIRUMALAI NAICKER COLLEGE (AUTONOMOUS) MADURAI DEPARTMENT OF COMPUTER SCIENCE (ARTIFICIAL INTELLIGENCE) BONAFIDE CERTIFICATE NAME : REG_NO : CLASS : I B. Sc (CS) AI SEMESTER : I SUBJECT : Programming in C Lab SUB.CODE : 23UAICP11 This is to certify that this record is a bonafide work done by the above- mentioned student. The certificate is awarded for the same. HEAD OF THE DEPARTMENT STAFF IN-CHARGE Submitted for Practical Examination held on _____________ at Mannar Thirumalai Naicker College, Pasumalai, Madurai. INTERNAL EXAMINER EXTERNAL EXAMINER
  • 3. PROGRAMMING IN C LAB CONTENTS S.No. Date Title Page No. Signature 1. ADDITION OF TWO INTEGERS 2. MULTIPLY TWO FLOATING NUMBERS 3. WRITE A CHARACTER AND STRING 4. SWAPPING NUMBERS 5. EVEN OR ODD 6. CHECK VOWEL OR CONSONANT 7. SIMPLE INTEREST CALCULATION 8. LARGEST AMONG THREE NUMBERS 9. SUM OF N NATURAL NUMBERS 10. FACTORIAL OF A NUMBER 11. DISPLAY PRIME NUMBERS BETWEEN TWO INTERVALS 12. SIMPLE CALCULATOR 13 SWAPPING TWO NUMBERS USING FUNCTION 14 FACTORIAL OF N NUMBER USING RECURSION 15 STRUCTURES FOR EMPLOYEE INFORMATION 16 POINTERS 17 FILE OPERATIONS
  • 4. 1 EX. NO :1. ADDITION OF TWO INTEGERS Aim: To write a c program to add two integers. Program: #include <stdio.h> #include<conio.h> void main() { int number1,number2,sum; printf(“Enter two integers:”); scanf("%d %d", &number1, &number2); sum = number1 + number2; printf("%d + %d = %d", number1, number2, sum); getch(); } Output: Enter two integers: 5 7 5 + 7 = 12 Result: Thus the program has been successfully created.
  • 5. 2 EX.NO:2.MULTIPLY TWO FLOATING NUMBERS Aim: To write c program to multiply two floating numbers. Program: #include <stdio.h> #include<conio.h> void main() { double a, b, product; printf("Enter two numbers: "); scanf("%lf %lf", &a, &b); Product=a*b; Printf(“Product=%2lf”,Product); getch(); Output: Enter two numbers :2.4 1.24 Product = 2.98 Result: Thus the program has been successfully created.
  • 6. 3 EX.NO:3.WRITE A CHARACTER AND STRING IN C Aim: To write a c program to read a single character, string and sentence as input. 1. Single character: Program: #include <stdio.h> #include<conio.h> void main(){ char ch; printf(“Enter the name:”); scanf(“%c”,&ch); printf(“Output:%c”,ch); getch(); } Output: Enter the name: Artificial Intelligence Output:A 2. Reading a word in c Program: #include<stdio.h> #include<conio.h> void main(){ char word[100]; printf(“Enter the word:”); scanf(“%s”,word);
  • 7. 4 printf(“output:%s”,word); getch(); } Output: Enter the name: Artificial Intelligence Output: Artificial Intelligence Result: Thus the program has been successfully created.
  • 8. 5 EX.NO: 4. SWAPPING NUMBERS Aim: To write a c program to swap two numbers. Program: #include<stdio.h> #include<conio.h> void main() { double first, second, temp; printf("Enter first number: "); scanf("%lf", &first); printf("Enter second number: "); scanf("%lf", &second); temp = first; first = second; second = temp; printf("nAfter swapping, first number = %.2lfn", first); printf("After swapping, second number = %.2lf", second); getch(); } Output: Enter first number: 1.20 Enter second number: 3.3 After swapping, first number = 3.30 After swapping, second number = 1.20 Result: Thus the program has been successfully created.
  • 9. 6 EX.NO: 5. EVEN OR ODD Aim: To write a program in c to check whether the number is even or odd. Program: #include <stdio.h> #include <conio.h> void main() { int num; printf("Enter an integer: "); scanf("%d", &num); if(num % 2 == 0) printf("%d is even.", num); else printf("%d is odd.", num); getch(); } Output: Enter an integer:28 28 is even. Enter an integer:35 35 is odd.
  • 10. 7 EX.NO:6.TO CHECK VOWEL OR CONSONANT Aim: To write a program in c to check the letter as vowel or consonant. Program: #include <stdio.h> #include<conio.h> void main() { char c; int lowercase_vowel, uppercase_vowel; printf("Enter an alphabet: "); scanf("%c", &c); lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') if (lowercase_vowel || uppercase_vowel) printf("%c is a vowel.", c); else printf("%c is a consonant.", c); getch(); } Output: Enter an alphabet: y y is a consonant. Enter an alphabet: e e is a vowel. Result: Thus the program has been successfully created.
  • 11. 8 EX.NO:7. SIMPLE INTEREST CALCULATION Aim: To calculate the simple interest using C program. Program: #include<stdio.h> #include<conio.h> void main() { int P,R,T; double SI; printf("Enter the principle:"); scanf("%d",&P); printf("Enter the rate:"); scanf("%d",&R); printf("Enter the time:"); scanf("%d",&T); SI=(P*R*T)/100; printf("The simple interest is %d",SI); getch(); } Output: Enter the Principal: 1300 Enter the Rate: 12 Enter the Time: 2 The Simple Interest is:3120.0 Result: Thus the program has been successfully created.
  • 12. 9 EX.NO:8. LARGEST AMONG THREE NUMBERS Aim: To write c program to find the maximum number out of the three. Program: #include<stdio.h> #include<conio.h> void main() { int A,B,C; printf("Enter the numbers A,B,and C:"); scanf("%d%d%d",&A,&B,&C); if(A>=B&&A>=C) printf("%d is the largest number:",A); else if(B>=A&&B>=C) printf("%d is the largest number:",B); else printf("%d is the largest number:",C); getch(); } Output: Result: Thus the program has been successfully created.
  • 13. 10 EX .NO:9. SUM OF n NATURAL NUMBERS Aim: To write a c program for sum of n natural numbers . Program: #include<stdio.h> #include<conio.h> void main() { Printf(“SUM OF N NATURAL NUMBERSn”); Printf(“===========================n”); int i,s-=0; int n=10; for (i=0;i<=n;i++) { s+=i; } printf("Sum= %d ",s); getch(); } OUTPUT: Result: Thus the program has been successfully created.
  • 14. 11 EX NO:10 FACTORIAL OF A NUMBER Aim: To write a factorial number Program: #include <stdio.h> #include <conio.h> void main(){ int n,i; unsigned long long fact=1; clrscr(); printf("FACTORIAL"); printf("n---------n"); printf("Enter an integer :"); scanf("%d",&n); if(n<0) printf("Error!,Factorial of negative number does'nt exist"); else for(i=1;i<=n;++i) { fact*=i; } printf("Factorial of %d=%llu",n,fact); getch(); }
  • 15. 12 Output: Result: Thus the program has been successfully created.
  • 16. 13 EX NO:11 DISPLAY PRIME NUMBERS BETWEEN TWO INTERVALS Aim: To display the prime numbers between two intervals Program: #include<stdio.h> #include <conio.h> void main() { clrscr(); int low ,high,i,flag; printf("Enter two intervals :"); scanf("%d%d",&low,&high); printf("Prime number between %d and %d are:",low,high); while(low<high){ flag=0; if(low<=1){ ++low; continue; } for(i=2;i<=low/2;++i) { if(low % i==0){ flag=1; break; } }
  • 18. 15 EX NO:12 SIMPLE CALCULATOR USING SWITCH STATEMENT Aim: To calculate the program using switch statement Program: #include<stdio.h> #include<conio.h> void main(){ clrscr(); char op; double first,second; printf("SIMPLE CALCULATOR"); printf("n------ ----------n"); printf("Enter an operator (+,-,*,/):"); scanf("%c",&op); printf("Enter two operands:"); scanf("%lf%lf",&first,&second); switch (op){ case'+': printf("%1lf+%1lf=%1lf",first,second,first+second); break; case'-': printf("%1lf-%1lf=%1lf",first,second,first-second); break; case'*': printf("%1lf*%1lf=%1lf",first,second,first*second); break;
  • 19. 16 case'/': printf("%1lf/%1lf=%1lf",first,second,first/second); break; default: printf("Error!Operator is not correct"); } getch(); } Output: Result: Thus the program has been successfully created.
  • 20. 17 EX.NO: 13. SWAPPING TWO NUMBERS USING FUNCTION Aim: To write a c program to swap two numbers using function. Program: #include<stdio.h> #include<conio.h> void swap(int,int); int main() { int a,b; printf("Enter values for a and bn"); scanf("%d%d",&a,&b); printf("nnBefore swapping: a = %d and b = %dn",a,b); swap(a,b); return 0; } void swap (int x,int y) { int temp; temp=x; x=y; y=temp; printf("nAfter swapping:a=%d and b=%dn",x,y); } Output: Result: Thus the program has been successfully created.
  • 21. 18 EX NO:14 FACTORIAL OF N NUMBER USING RECURSION Aim: To write a c program for factorial of n numbers using function Program: #include<stdio.h> long factorial(int n) { if (n == 0) return 1; else return(n * factorial(n-1)); } void main() { int number; long fact; printf("Enter a number: "); scanf("%d", &number); fact = factorial(number); printf("Factorial of %d is %ldn", number, fact); return 0; } Output: Enter a number: 6 Factorial of 5 is: 720 Result: Thus the program has been successfully created.
  • 22. 19 EX NO:15 STRUCTURES FOR EMPLOYEE DETAIL AIM: To write a c program to print employee information using structure Program: #include <stdio.h> /*structure declaration*/ struct employee{ char name[30]; int empId; float salary; }; int main() { /*declare structure variable*/ struct employee emp; /*read employee details*/ printf("nEnter details :n"); printf("Name :"); gets(emp.name); printf("ID :"); scanf("%d",&emp.empId); printf("Salary :"); scanf("%f",&emp.salary); /*print employee details*/ printf("nEntered detail is:"); printf("Name: %s" ,emp.name); printf("Id: %d" ,emp.empId); printf("Salary: %fn",emp.salary); return 0; }
  • 23. 20 OUTPUT: Result: Thus the program has been successfully created.
  • 24. 21 EX NO:16 PROGRAM FOR POINTERS Aim: To write a c program for pointers Program: #include <stdio.h> void geeks() { int var = 10; ble int* ptr; ptr = &var; printf("Value at ptr = %p n", ptr); printf("Value at var = %d n", var); printf("Value at *ptr = %d n", *ptr); } // Driver program int main() { geeks(); return 0; } Output: Result: Thus the program has been successfully created.
  • 25. 22 EX NO:17 PROGRAM FOR FILE CREATION Aim: To Write a program to create a file called emp.rec and store information about a person, in terms of his name, age and salary. Program: #include<stdio.h> #include <conio.h> #include<stdlib.h> void main() { FILE *fptr; char name[20]; int age; float salary; fptr = fopen("emp.rec", "w"); if (fptr == NULL) { printf("File does not exists n"); return; } printf("Enter the name n"); scanf("%s", name); fprintf(fptr, "Name = %sn", name); printf("Enter the agen"); scanf("%d", &age); fprintf(fptr, "Age = %dn", age); printf("Enter the salaryn"); scanf("%f", &salary); fprintf(fptr, "Salary = %.2fn", salary);
  • 26. 23 fclose(fptr); } Output: Result: Thus the program has been successfully created.
  翻译: