SlideShare a Scribd company logo
1 of 30
Plot No.2, Sector 17-A, Yamuna Expressway, Greater Noida, Gautam Buddh Nagar, U.P., India
School of Computing Science and
Engineering
Lab Report
Exploration with CAS-I
BCS01T1003_PR
B.Tech. (First Sem.2022-2023)
Submitted by: Submitted to: Dr . Monika
Jain
Name: Syed Fuzail
Batch: 20
Adm. No.:22SCSE1011555
Lab Sheet #1
Q1: Write a program to display “hello world” in C.
Program 1:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
printf("Hello world");
return 0;
}
Output :
Q2: Write a program to add two numbers (5&7) and
display it’s sum.
Program 2:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int a=5,b=7,sum;
sum=a+b;
printf("Sum equals to %d",sum);
return 0;
}
Output:
Q3: Write a program to multiply two numbers (10&8)
and display its result.
Program 3:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int a=10,b=8,product;
product=a*b;
printf("Product equals to %d",product);
return 0;
}
Output:
Q4: Write a program to calculate the area of a circle of
radius (r=5).
Program 4:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int radius=5;
float area;
area=2*3.14*radius;
printf("Area of cirlce equals to %f",area);
return 0;
}
Output:
Q5: Write a program to calculate area of an ellipse having
it’s axes (minor=4cm, major=6cm).
Program 5:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int major=6,minor=4;
float area;
area=3.14*major*minor;
printf("Area of ellipse equals to %f",area);
return 0;
}
Output:
Q6: Write a program to calculate simple interest for a given
P=4000, T=2, r=5.5.
Program 6:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int p=4000,t=2;
float si,r=5.5;
si=(p*r*t)/100;
printf("Simple Intrest equals to %f",si);
return 0;
}
Output:
Lab Sheet #2
Q1:Write a program to declare two integer and one float
variable then intialize them to 10, 15, 12.6. Also print the
values in the screen.
Program 1:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int a=10,b=15;
float c=12.6;
printf("Integer values are n%d n%d nFloat value aren%f",a,b,c);
return 0;
}
Output:
Q2:Write a C program to prompt the user to input 3 integer
values and print these values in forward and reversed order.
Program 2:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enter three integer number");
scanf("%d%d%d",&a,&b,&c);
printf("Forward order %d %d %dn",a,b,c);
printf("Reverse order %d %d %d",c,b,a);
return 0;
}
Output:
Q3:Write a program to calculate simple and compound
interest.
Program 3:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
#include<math.h>
int main()
{
int p,r,t;
float si,ci;
printf("Enter the principle, rate, time to calculate the simple and
compond intrest");
scanf("%d%d%d",&p,&r,&t);
si=(p*r*t)/100;
ci=p*pow((1+ r/100),t);
printf("Simple intrest equals to %f nCompound intrest equals
to %f",si,ci);
return 0;
}
Output:
Q4:Write a program to swap two variables' values with and
without using third variables.
(a) With Variable
Program 4(a):
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enterthe value of a and b respectively to swap the value");
scanf("%d%d",&a,&b);
c=a;
a=b;
printf("n Swapped value of a=%d",a);
b=c;
printf("nSwapped value of b=%d",b);
return 0;
}
Output:
(b) Without third variable:
Program 4(b):
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int a,b;
printf("Enter the value of a and b respectively to swap the value");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("n Swapped value of a=%d",a);
printf("nSwapped value of b=%d",b);
return 0;
}
Output:
Q5: Write a program to check odd or even number (a)
using modulus operator (b) using bitwise operator (c)
without using bitwise and modulus operator (d) using
conditional operator.
Program 5(a):
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int x;
printf("n Enter any number to check it is a odd number or even
number.");
scanf("%d",&x);
if(x%2==0)
{
printf("n Entered number %d is a even number.",x);
}
else
{
printf("n Entered number %d is a odd number.",x);
}
return 0;
}
Output:
Program 5(b):
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int x;
printf("n Enter any number to check it is a odd number or even
number.");
scanf("%d",&x);
if((x & 1)==1)
{
printf("n Entered number %d is a odd number.",x);
}
else
{
printf("n Entered number %d is a even number.",x);
}
return 0;
}
Output:
Program 5(c):
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int x;
printf("n Enter any number to check it is a odd number or even
number.");
scanf("%d",&x);
if((x>>1)<<1==x)
{
printf("n Entered number %d is a even number.",x);
}
else
{
printf("n Entered number %d is a odd number.",x);
}
return 0;
}
Output:
Program 5(d):
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int x;
printf("n Enter any number to check it is a odd number or even
number.");
scanf("%d",&x);
printf("The number is %s",(x%2==0 ? "EVEN" : "ODD"));
return 0;
}
Output:
Q6. Print the value of y for given x=2 & z=4 and analyze
the output.
a. y = x++ + ++x;
b. y= ++x + ++x;
c. y= ++x + ++x + ++x;
d. y = x>z;
e. y= x>z? x:z;
f. y = x&z;
g. y= x>>2 + z<<1;
Program 6: Output:
// Syed Fuzail
// 22SCSE1011555
#include <stdio.h>
int main()
{
int x=2,z=4,y;
y=x++ + ++x;
printf("(a) Solution %dn",y);
y=++x + ++x;
printf("(b) Solution %dn",y);
y=++x + ++x + ++x;
printf("(c) Solution %d n",y);
y=x>2;
printf("(d) Solution %d n",y);
y=x>z ? x:z;
printf("(e) Solution %d n",y);
y=x&z;
printf("(f) Solution %d n",y);
y=x>>2 + z<<1;
printf("(g) Solution %d n",y);
return 0;
}
Q7. Write a program to print the size of char, float, double
and long double data types in C.
Program 7:
#include <stdio.h>
int main()
{
char a;
float b;
double c;
long double d;
printf("Enter any character n");
scanf("%c",&a);
printf("Enter any decimal valuen");
scanf("%f",&b);
printf("Enter any long value with decimaln");
scanf("%ld",&c);
printf("Enter any extra long value n");
scanf("%ld",&d);
return 0;
}
Output:
Lab Sheet #3
Q1.Write a program to find the largest and smallest among
three entered numbers and also display whether the
identified largest/smallest number is even or odd.
Program 1:
//Syed Fuzail
//22SCSE1011555
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enter any three numbers.n");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
{
printf("%d is greater than %d and %dn",a,b,c);
if(a%2==0)
{
printf("%d is evenn",a);
}
else
{
printf("%d is oddn",a);
}
}
if(b>c && b>a)
{
printf("%d is greater than %d and %dn",b,a,c);
if(b%2==0)
{
printf("%d is evenn",b);
}
else
{
printf("%d is oddn",b);
}
}
if(c>a && c>b)
{
printf("%d is greater than %d and %d",c,a,b);
if(c%2==0)
{
printf("%d is evenn",c);
}
else
{
printf("%d is oddn",c);
}
}
if(a<b && a<c)
{
printf("%d is smaller than %d and %dn",a,b,c);
if(a%2==0)
{
printf("%d is evenn",a);
}
else
{
printf("%d is oddn",a);
}
}
if(b<c && b<c)
{
printf("%d is smaller than %d and %dn",b,a,c);
if(a%2==0)
{
printf("%d is evenn",b);
}
else
{
printf("%d is oddn",b);
}
}
if(c<b && c<a)
{
printf("%d is smaller than %d and %dn",c,a,b);
if(c%2==0)
{
printf("%d is evenn",c);
}
else
{
printf("%d is oddn",c);
}
}
return 0;
}
Output:
Q2:Write a program to check whether input alphabet is
vowel or not using if-else and switch statement.
Program 2:
Using If-else statement
//Syed Fuzail
//22SCSE1011555
#include <stdio.h>
int main()
{
char v;
printf("Enter any alphabet.n");
scanf("%c",&v);
if(v=='a'||v=='e'||v=='i'||v=='o'||v=='u'||v=='A'||v=='E'||v=='I'||v=='O'||
v=='U')
{
printf("Entered alphabet %c is vowel.",v);
}
else
{
printf("Entered alphabet %c is consonant",v);
}
return 0;
}
Output:
Using Switch Statement
//Syed Fuzail
//22SCSE1011555
#include <stdio.h>
int main()
{
char v;
printf("Enter any alphabet.n");
scanf("%c",&v);
switch(v)
{
case'a':
printf("Vowel");
break;
case'e':
printf("Vowel");
break;
case'i':
printf("Vowel");
break;
case'o':
printf("Vowel");
break;
case'u':
printf("Vowel");
break;
case'A':
printf("Vowel");
break;
case'E':
printf("Vowel");
break;
case'I':
printf("Vowel");
break;
case'O':
printf("Vowel");
break;
case'U':
printf("Vowel");
break;
default:
printf("Consonant");
}
return 0;
}
Output:
Q3. Write a program to get input of two or higher digit
integer number and display in reverse order.
Program 3:
// Syed Fuzail
//22SCSE1011555
#include <stdio.h>
int main()
{
int n, reverse = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while (n != 0)
{
remainder = n % 10;
reverse = reverse * 10 + remainder;
n /= 10;
}
printf("Reversed number = %d", reverse);
return 0;
}
Output:
Q4. Write a program that asks a number and test the
number whether it is multiple of 5 or not, divisible by 7 but
not by eleven.
Program 4:
//Syed Fuzail
//22SCSE1011555
#include <stdio.h>
int main()
{
int n;
printf("Enter any number.n");
scanf("%d",&n);
if(n%5==0)
{
printf("%d is multiple of 5. n",n);
}
else
{
printf("%d is not multiple of 5.n",n);
}
if((n%7==0)&& (n%11!=0))
{
printf("Given Number is also divisible by 7 but not by 11.");
}
else
{
printf("Not divisible by 7 and 11");
}
return 0;
}
Output:
Q5. Write a program to check whether the entered year is
leap year or not (a year is leap if it is divisible by 4 and
divisible by 100 or 400.)
Program 5:
//Syed Fuzail
//22SCSE1011555
#include <stdio.h>
int main()
{
int a;
printf("Enter any year to check leap year or not");
scanf("%d",&a);
if((a%4==0)||(a%400==0)&&(a%100==0))
{
printf("n %d is a leap year",a);
}
else
{
printf("n %d is not a leap year",a);
}
return 0;
}
Output:
Q6. Write a program to read the values of coefficients a, b
and c of a quadratic equation ax2+bx+c=0 and find roots of
the equation.
Program 6:
//Syed Fuzail
//22SCSE1011555
#include <math.h>
#include <stdio.h>
int main() {
double a, b, c, discriminant, root1, root2, realPart, imagPart;
printf("Enter coefficients a, b and c: ");
scanf("%lf %lf %lf", &a, &b, &c);
discriminant = b * b - 4 * a * c;
// condition for real and different roots
if (discriminant > 0) {
root1 = (-b + sqrt(discriminant)) / (2 * a);
root2 = (-b - sqrt(discriminant)) / (2 * a);
printf("root1 = %.2lf and root2 = %.2lf", root1, root2);
}
// condition for real and equal roots
else if (discriminant == 0) {
root1 = root2 = -b / (2 * a);
printf("root1 = root2 = %.2lf;", root1);
}
// if roots are not real
else {
realPart = -b / (2 * a);
imagPart = sqrt(-discriminant) / (2 * a);
printf("root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi", realPart,
imagPart, realPart, imagPart);
}
return 0;
}
Output:

More Related Content

Similar to Fuzail_File_C.docx

Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
Simple C programs
Simple C programsSimple C programs
Simple C programsab11cs001
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programsPrasadu Peddi
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
A10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptxA10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptxranjangamer007
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfjanakim15
 

Similar to Fuzail_File_C.docx (20)

Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Hargun
HargunHargun
Hargun
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
C programs
C programsC programs
C programs
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
 
Technical quiz 5#.pptx
Technical quiz 5#.pptxTechnical quiz 5#.pptx
Technical quiz 5#.pptx
 
Automata fix.pdf
Automata fix.pdfAutomata fix.pdf
Automata fix.pdf
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
A10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptxA10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptx
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdf
 

Recently uploaded

Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 

Recently uploaded (20)

Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 

Fuzail_File_C.docx

  • 1. Plot No.2, Sector 17-A, Yamuna Expressway, Greater Noida, Gautam Buddh Nagar, U.P., India School of Computing Science and Engineering Lab Report Exploration with CAS-I BCS01T1003_PR B.Tech. (First Sem.2022-2023) Submitted by: Submitted to: Dr . Monika Jain Name: Syed Fuzail Batch: 20 Adm. No.:22SCSE1011555
  • 2. Lab Sheet #1 Q1: Write a program to display “hello world” in C. Program 1: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { printf("Hello world"); return 0; } Output :
  • 3. Q2: Write a program to add two numbers (5&7) and display it’s sum. Program 2: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int a=5,b=7,sum; sum=a+b; printf("Sum equals to %d",sum); return 0; } Output:
  • 4. Q3: Write a program to multiply two numbers (10&8) and display its result. Program 3: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int a=10,b=8,product; product=a*b; printf("Product equals to %d",product); return 0; } Output:
  • 5. Q4: Write a program to calculate the area of a circle of radius (r=5). Program 4: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int radius=5; float area; area=2*3.14*radius; printf("Area of cirlce equals to %f",area); return 0; } Output:
  • 6. Q5: Write a program to calculate area of an ellipse having it’s axes (minor=4cm, major=6cm). Program 5: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int major=6,minor=4; float area; area=3.14*major*minor; printf("Area of ellipse equals to %f",area); return 0; } Output:
  • 7. Q6: Write a program to calculate simple interest for a given P=4000, T=2, r=5.5. Program 6: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int p=4000,t=2; float si,r=5.5; si=(p*r*t)/100; printf("Simple Intrest equals to %f",si); return 0; } Output:
  • 8. Lab Sheet #2 Q1:Write a program to declare two integer and one float variable then intialize them to 10, 15, 12.6. Also print the values in the screen. Program 1: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int a=10,b=15; float c=12.6; printf("Integer values are n%d n%d nFloat value aren%f",a,b,c); return 0; } Output:
  • 9. Q2:Write a C program to prompt the user to input 3 integer values and print these values in forward and reversed order. Program 2: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int a,b,c; printf("Enter three integer number"); scanf("%d%d%d",&a,&b,&c); printf("Forward order %d %d %dn",a,b,c); printf("Reverse order %d %d %d",c,b,a); return 0; } Output:
  • 10. Q3:Write a program to calculate simple and compound interest. Program 3: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> #include<math.h> int main() { int p,r,t; float si,ci; printf("Enter the principle, rate, time to calculate the simple and compond intrest"); scanf("%d%d%d",&p,&r,&t); si=(p*r*t)/100; ci=p*pow((1+ r/100),t); printf("Simple intrest equals to %f nCompound intrest equals to %f",si,ci); return 0; } Output:
  • 11. Q4:Write a program to swap two variables' values with and without using third variables. (a) With Variable Program 4(a): // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int a,b,c; printf("Enterthe value of a and b respectively to swap the value"); scanf("%d%d",&a,&b); c=a; a=b; printf("n Swapped value of a=%d",a); b=c; printf("nSwapped value of b=%d",b); return 0; } Output:
  • 12. (b) Without third variable: Program 4(b): // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int a,b; printf("Enter the value of a and b respectively to swap the value"); scanf("%d%d",&a,&b); a=a+b; b=a-b; a=a-b; printf("n Swapped value of a=%d",a); printf("nSwapped value of b=%d",b); return 0; } Output:
  • 13. Q5: Write a program to check odd or even number (a) using modulus operator (b) using bitwise operator (c) without using bitwise and modulus operator (d) using conditional operator. Program 5(a): // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int x; printf("n Enter any number to check it is a odd number or even number."); scanf("%d",&x); if(x%2==0) { printf("n Entered number %d is a even number.",x); } else { printf("n Entered number %d is a odd number.",x); } return 0; } Output:
  • 14. Program 5(b): // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int x; printf("n Enter any number to check it is a odd number or even number."); scanf("%d",&x); if((x & 1)==1) { printf("n Entered number %d is a odd number.",x); } else { printf("n Entered number %d is a even number.",x); } return 0; } Output:
  • 15. Program 5(c): // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int x; printf("n Enter any number to check it is a odd number or even number."); scanf("%d",&x); if((x>>1)<<1==x) { printf("n Entered number %d is a even number.",x); } else { printf("n Entered number %d is a odd number.",x); } return 0; } Output:
  • 16. Program 5(d): // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int x; printf("n Enter any number to check it is a odd number or even number."); scanf("%d",&x); printf("The number is %s",(x%2==0 ? "EVEN" : "ODD")); return 0; } Output:
  • 17. Q6. Print the value of y for given x=2 & z=4 and analyze the output. a. y = x++ + ++x; b. y= ++x + ++x; c. y= ++x + ++x + ++x; d. y = x>z; e. y= x>z? x:z; f. y = x&z; g. y= x>>2 + z<<1; Program 6: Output: // Syed Fuzail // 22SCSE1011555 #include <stdio.h> int main() { int x=2,z=4,y; y=x++ + ++x; printf("(a) Solution %dn",y); y=++x + ++x; printf("(b) Solution %dn",y); y=++x + ++x + ++x; printf("(c) Solution %d n",y); y=x>2; printf("(d) Solution %d n",y); y=x>z ? x:z; printf("(e) Solution %d n",y); y=x&z; printf("(f) Solution %d n",y); y=x>>2 + z<<1; printf("(g) Solution %d n",y); return 0; }
  • 18. Q7. Write a program to print the size of char, float, double and long double data types in C. Program 7: #include <stdio.h> int main() { char a; float b; double c; long double d; printf("Enter any character n"); scanf("%c",&a); printf("Enter any decimal valuen"); scanf("%f",&b); printf("Enter any long value with decimaln"); scanf("%ld",&c); printf("Enter any extra long value n"); scanf("%ld",&d); return 0; } Output:
  • 19. Lab Sheet #3 Q1.Write a program to find the largest and smallest among three entered numbers and also display whether the identified largest/smallest number is even or odd. Program 1: //Syed Fuzail //22SCSE1011555 #include <stdio.h> int main() { int a,b,c; printf("Enter any three numbers.n"); scanf("%d%d%d",&a,&b,&c); if(a>b && a>c) { printf("%d is greater than %d and %dn",a,b,c); if(a%2==0) { printf("%d is evenn",a); } else { printf("%d is oddn",a); } } if(b>c && b>a) { printf("%d is greater than %d and %dn",b,a,c); if(b%2==0) { printf("%d is evenn",b); } else
  • 20. { printf("%d is oddn",b); } } if(c>a && c>b) { printf("%d is greater than %d and %d",c,a,b); if(c%2==0) { printf("%d is evenn",c); } else { printf("%d is oddn",c); } } if(a<b && a<c) { printf("%d is smaller than %d and %dn",a,b,c); if(a%2==0) { printf("%d is evenn",a); } else { printf("%d is oddn",a); } } if(b<c && b<c) { printf("%d is smaller than %d and %dn",b,a,c); if(a%2==0) { printf("%d is evenn",b); } else { printf("%d is oddn",b); }
  • 21. } if(c<b && c<a) { printf("%d is smaller than %d and %dn",c,a,b); if(c%2==0) { printf("%d is evenn",c); } else { printf("%d is oddn",c); } } return 0; } Output:
  • 22. Q2:Write a program to check whether input alphabet is vowel or not using if-else and switch statement. Program 2: Using If-else statement //Syed Fuzail //22SCSE1011555 #include <stdio.h> int main() { char v; printf("Enter any alphabet.n"); scanf("%c",&v); if(v=='a'||v=='e'||v=='i'||v=='o'||v=='u'||v=='A'||v=='E'||v=='I'||v=='O'|| v=='U') { printf("Entered alphabet %c is vowel.",v); } else { printf("Entered alphabet %c is consonant",v); } return 0; } Output:
  • 23. Using Switch Statement //Syed Fuzail //22SCSE1011555 #include <stdio.h> int main() { char v; printf("Enter any alphabet.n"); scanf("%c",&v); switch(v) { case'a': printf("Vowel"); break; case'e': printf("Vowel"); break; case'i': printf("Vowel"); break; case'o': printf("Vowel"); break; case'u': printf("Vowel"); break; case'A': printf("Vowel"); break; case'E': printf("Vowel"); break; case'I': printf("Vowel"); break;
  • 25. Q3. Write a program to get input of two or higher digit integer number and display in reverse order. Program 3: // Syed Fuzail //22SCSE1011555 #include <stdio.h> int main() { int n, reverse = 0, remainder; printf("Enter an integer: "); scanf("%d", &n); while (n != 0) { remainder = n % 10; reverse = reverse * 10 + remainder; n /= 10; } printf("Reversed number = %d", reverse); return 0; } Output:
  • 26. Q4. Write a program that asks a number and test the number whether it is multiple of 5 or not, divisible by 7 but not by eleven. Program 4: //Syed Fuzail //22SCSE1011555 #include <stdio.h> int main() { int n; printf("Enter any number.n"); scanf("%d",&n); if(n%5==0) { printf("%d is multiple of 5. n",n); } else { printf("%d is not multiple of 5.n",n); } if((n%7==0)&& (n%11!=0)) { printf("Given Number is also divisible by 7 but not by 11."); } else { printf("Not divisible by 7 and 11"); } return 0; }
  • 28. Q5. Write a program to check whether the entered year is leap year or not (a year is leap if it is divisible by 4 and divisible by 100 or 400.) Program 5: //Syed Fuzail //22SCSE1011555 #include <stdio.h> int main() { int a; printf("Enter any year to check leap year or not"); scanf("%d",&a); if((a%4==0)||(a%400==0)&&(a%100==0)) { printf("n %d is a leap year",a); } else { printf("n %d is not a leap year",a); } return 0; } Output:
  • 29. Q6. Write a program to read the values of coefficients a, b and c of a quadratic equation ax2+bx+c=0 and find roots of the equation. Program 6: //Syed Fuzail //22SCSE1011555 #include <math.h> #include <stdio.h> int main() { double a, b, c, discriminant, root1, root2, realPart, imagPart; printf("Enter coefficients a, b and c: "); scanf("%lf %lf %lf", &a, &b, &c); discriminant = b * b - 4 * a * c; // condition for real and different roots if (discriminant > 0) { root1 = (-b + sqrt(discriminant)) / (2 * a); root2 = (-b - sqrt(discriminant)) / (2 * a); printf("root1 = %.2lf and root2 = %.2lf", root1, root2); } // condition for real and equal roots else if (discriminant == 0) { root1 = root2 = -b / (2 * a); printf("root1 = root2 = %.2lf;", root1); } // if roots are not real else { realPart = -b / (2 * a); imagPart = sqrt(-discriminant) / (2 * a); printf("root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi", realPart, imagPart, realPart, imagPart); }