#Include #Include Void Int Float
#Include #Include Void Int Float
#include <stdio.h>
#include <conio.h>
void main()
{
int age;
float amount;
printf("Enter your age & amount=");
scanf_s("%d %f", &age, &amount);
printf("\nYou are %d years old & you have %f rupees.", age, amount);
_getch();
Output
OUTPUT
OutPut
Q4
#include<stdio.h>
#include<conio.h>
int factorial(int n)
if (n < 0)
n = -n;
int ans = 1;
ans = ans*i;
return -ans;
if (n > 0)
int ans = 1;
ans = ans*i;
return ans;
if (n == 0)
return 1;
void main()
int a, b;
printf("Enter Number which factorial is to be determined=");
scanf_s("%d", &a);
b = factorial(a);
printf("\n%d", b);
_getch();
Q=5
#include<stdio.h>
#include<conio.h>
if (y < 0)
{
float ans = 1;
y = -y;
ans = ans*x;
return 1 / ans;
if (y > 0)
float ans = 1;
ans = ans*x;
return ans;
if (y == 0)
return 1;
void main()
{
float a, b, c;
c = pow(a, b);
_getch();
Output
Q=6
#include<stdio.h>
#include<conio.h>
void primenumber(int num);
int i;
if (num%i == 0)
break;
if (i == num)
void main()
int p;
printf("Enter a number");
scanf_s("%d", &p);
primenumber(p);
_getch();
}
Output
Q=7
#include<stdio.h>
#include<conio.h>
void main(){
float marks[5];
printf("marks[%d]?", i);
scanf_s("%f", &marks[i]);
printf("%.0f\t", marks[i]);
_getch();
Output
Q=8
#include<stdio.h>
#include<conio.h>
printf("%.0f\t", nums[i]);
nums[0] = 99;
printf("\n");
}
void main() {
int length = 3;
printArray(x, length);
printArray(x, length);
_getch();
Output
Q=9
#include<stdio.h>
#include<conio.h>
addarray(x, y, z, length);
printarray(x, length);
printarray(y, length);
printarray(z, length);
_getch();
}
Output
Q=10
#include<stdio.h>
#include<conio.h>
printf("nums[%d}=?", i);
scanf_s("%f", &nums[i]);
printf("%f\t",nums[i]);
printf("\n");
void main(){
int length = 3;
float x[3];
float y[3];
float z[3];
inputarray(x, length);
inputarray(y, length);
addarray(x, y, z, length);
printarray(x, length);
printarray(y, length);
printarray(z, length);
_getch();
Output
Q=11
#include<stdio.h>
#include<conio.h>
float ans = 0;
return ans;
void main(){
float x[4] = { 4, 3, 4, 5 };
printf("avg= %.2f", avgarray(x, 4));
_getch();
Output
Q=12
#include<stdio.h>
#include<conio.h>
printf("nums[%d}=?", i);
scanf_s("%f", &nums[i]);
}
float sumarray(float nums[], int length);
float ans = 0;
return ans;
void main(){
int length = 3;
float x[3];
inputarray(x, length);
float b;
b = avgarray(x, length);
printf("avg= %.2f",b);
_getch();
Output
Q=13
#include<stdio.h>
#include<conio.h>
printf("%f\t",nums[i]);
printf("\n");
minimums = nums[i];
return minimums;
}
void main(){
int length = 5;
float nums[] = { 5, 7, 3, 2, 4 };
printarray(nums, length);
_getch();
Output
Q 14
#include<stdio.h>
#include<conio.h>
#include<math.h>
if (disc < 0)
return;
void main(){
float a, b, c;
printf("enter a");
scanf_s("%f", &a);
printf("enter b");
scanf_s("%f", &b);
printf("enter c");
scanf_s("%f", &c);
float x[2];
quadroots(a, b, c, x);
_getch();
Output
Q=
#include<stdio.h>
#include<conio.h>
void main()
float x = 2;
float *p;
p = &x;
_getch();
Output
Q= Quadratic formula with pointers
#include<stdio.h>
#include<conio.h>
#include<math.h>
void quadroots(float a, float b, float c, float *p1, float *p2);
void quadroots(float a, float b, float c, float *p1, float *p2)
{
float disc = b*b - 4 * a*c;
if (disc < 0)
return;
*p1 = (-b + sqrt(disc)) / (2 * a);
*p2 = (-b - sqrt(disc)) / (2 * a);
}
void main()
{
float a = 1;
float b = 0;
float c = -4;
float x1, x2;
quadroots(a, b, c, &x1, &x2);
printf("a=%f\tb=%f\tc=%f", a, b, c);
printf("\nx1=%f\tx2=%f", x1, x2);
_getch();
}
Output
Q: Swapping
#include<conio.h>
#include<stdio.h>
void swap(float *px, float *py);
void swap(float *px, float *py)
{
float z = *px;
*px = *py;
*py = z;
}
void main()
{
float x = 2;
float y = 3;
printf("x=%f\ty=%f", x, y);
swap(&x , &y);
printf("\nx=%f\ty=%f",x, y);
_getch();
}
Output
Q=19
#include<stdio.h>
#include<conio.h>
float m = a;
if (b < m)
m = b;
if (c < m)
m = c;
if (d < m)
m = d;
return m;
}
void main()
float w, x, y, z;
w = 7;
x = 5;
y = 4;
z = 3;
_getch();
Q=20
#include<stdio.h>
#include<conio.h>
if (a < b)
return a;
else
return b;
void main()
float w, x, y, z;
w = 7;
x = 5;
y = 4;
z = 3;
_getch();
Output
Q=21
#include<stdio.h>
#include<conio.h>
#include<math.h>
int factorial(int n)
if (n < 0)
n = -n;
int ans = 1;
ans = ans*i;
return -ans;
}
if (n > 0)
int ans = 1;
ans = ans*i;
return ans;
if (n == 0)
return 1;
float sum = 0;
return sum;
void main()
{
float x = 1;
printf("%f", anyseries(x));
_getch();
Q=22
#include<stdio.h>
#include<conio.h>
float z = *px;
*px = *py;
*py = z;
}
void printarray(float nums[], int length);
printf("%f\t", nums[i]);
printf("\n");
if (nums[i]>nums[i + 1])
void main()
float nums[] = { 5, 2, 9, 3 };
printarray(nums, 4);
sortarray(nums, 4);
printarray(nums, 4);
_getch();
}
Output
Q=23
#include<stdio.h>
#include<conio.h>
float z = *px;
*px = *py;
*py = z;
printf("%f\t", nums[i]);
printf("\n");
if (asc == true)
if (nums[i]>nums[i + 1])
else
}
void main()
float nums[] = { 5, 2, 9, 3 };
printarray(nums, 4);
sortarray(nums, 4,true);
printarray(nums, 4);
sortarray(nums, 4, false);
printarray(nums, 4);
_getch();
Output
#include<stdio.h>
#include<conio.h>
printf("nums[%d}=?", i);
scanf_s("%f", &nums[i]);
printf("%f\t", nums[i]);
printf("\n");
void main()
int length;
printf("Define length?");
scanf_s("%d", &length);
float *nums;
inputarray(nums, length);
printarray(nums, length);
_getch();
}
Output
Q=25 Matrix
#include<stdio.h>
#include<conio.h>
printf("mat[%d][%d]?", i, j);
scanf_s("%f", &mat[i][j]);
}
}
}
void printmatrix(float **mat, int rows, int cols);
void printmatrix(float **mat, int rows, int cols){
for (int i = 0; i < rows; i++)
{
printf("\n");
for (int j = 0; j < cols; j++)
printf("%.2f\t", mat[i][j]);
}
printf("\n");
}
void main()
{
int rows, cols;
printf("Rows?");
scanf_s("%d", &rows);
printf("cols?");
scanf_s("%d", &cols);
_getch();
}
Q=26
#include<stdio.h>
#include<conio.h>
return mat;
printf("mat[%d][%d]?", i, j);
scanf_s("%f", &mat[i][j]);
printf("\n");
printf("%.2f\t", mat[i][j]);
printf("\n");
return matC;
void main()
printf("Rows?");
scanf_s("%d", &rows);
printf("cols?");
scanf_s("%d", &cols);
_getch();
Output
Q=27
#include<stdio.h>
#include<conio.h>
return mat;
{
printf("mat[%d][%d]?", i, j);
scanf_s("%f", &mat[i][j]);
printf("\n");
printf("%.2f\t", mat[i][j]);
printf("\n");
float **multiplymatrix(float **matA, float **matB, int rowsA, int colsA, int rowsB, int colsB);
float **multiplymatrix(float **matA, float **matB, int rowsA, int colsA, int rowsB, int colsB){
matC[i][j] = 0;
return matC;
void main()
printf("RowsA?");
scanf_s("%d", &rowsA);
printf("colsA?");
scanf_s("%d", &colsA);
printf("rowsB?");
scanf_s("%d", &rowsB);
printf("colsB?");
scanf_s("%d", &colsB);
else
_getch();
Output