Practical File For PPS
Practical File For PPS
Source Code
#include<stdio.h>
#include<conio.h>
void main ()
{
clrscr();
printf("hello");
getch();
}
Output
PROGRAM-2
Aim-To print your own name
Source Code
#include <stdio.h>
int main(void)
{
char name[25] ;
printf("what's your name ?") ;
scanf("%s", name) ;
printf ("your name is %s", name) ;
return 0 ;
}
Output
PROGRAM-3
Aim-To print the sum of two number
Source Code
#include <stdio.h>
int main()
{
int num1,num2,sum;
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
sum = num1 + num2;
printf("%d + %d = %d", num1, num2, sum);
return 0;
}
Output
Program-4
Aim- To find area of circle
Source Code
#include <stdio.h>
#define PI 3.14159
int main()
scanf("%f", &radius);
return 0;
Output
Program-5
Aim- To find simple interest
Source Code
#include <stdio.h>
int main()
scanf("%f", &principle);
scanf("%f", &time);
scanf("%f", &rate);
return 0;
}
Output
Program-6
Aim- To convert fahrenheit to celsius
#include<stdio.h>
#include<conio.h>
void main()
{
float fahren, celsius;
printf("enter temprature in fahrenheit=");
scanf("%f",&fahren);
celsius=(fahren-32)*5.0/9.0;
printf("%.2f fahrenheit is equal %.2f in celsius", fahren, celsius);
getch();
}
Output
PROGRAM-7
Aim-To find even and odd number
Source Code
#include <stdio.h>
int main()
{
int a;
printf("Enter a: ");
scanf("%d", &a);
//logic
if (a % 2 == 0) {
printf("The given number is EVEN");
}
else {
printf("The given number is ODD");
}
return 0;
}
Output
Program-8
Aim-To find greatest of three numbers using if only
Source Code
#include <stdio.h>
int main()
int a, b, c;
scanf("%d", &a);
printf("b: ");
scanf("%d", &b);
printf("c: ");
scanf("%d", &c);
return 0;
}
Output
Program-9
Aim- To find greatest of three numbers using if else
Source Code
#include <stdio.h>
int main()
return 0;
}}
Output
Program-10
AIM-To takes input at runtime for attendance and marks criteria and then
checks whether a student meets the attendance and marks criteria using nested if
statements.
Source Code
#include <stdio.h>
int main() {
scanf("%f", &attendance_criteria);
scanf("%f", &marks_criteria);
scanf("%f", &student_attendance);
scanf("%f", &student_marks);
return 0;
Output
Program- 11
#include<stdio.h>
void main()
int i;
printf("%d \t", i );
Output
Source Code using while loop
#include <stdio.h>
int main() {
int i = 1;
printf("%d\n", i);
i++;
return 0;
Output
Source Code using Do while loop
#include <stdio.h>
int main() {
int i = 1;
do {
printf("%d\n", i);
i++;
return 0;
Output
Program-12
AIM – To Print the Star pattern (right half pyramid and inverted right half pyramid)
int main()
int i, j, rows;
scanf("%d", &rows);
printf("* ");
printf("\n");
return 0;
Output
Source Code using while loop
#include <stdio.h>
int main() {
int i, j, rows;
scanf("%d", &rows);
i = 1;
j = 1;
while(j <= i) {
printf("* ");
j++;
printf("\n");
i++;
return 0;
Output
For inverted right half pyramid
int main() {
int i, j, rows;
scanf("%d", &rows);
printf("* ");
printf("\n");
return 0;
Output
Source Code using while loop
#include <stdio.h>
int main() {
int i, j, rows;
scanf("%d", &rows);
i = rows;
while(i >= 1) {
j = 1;
while(j <= i) {
printf("* ");
j++;
printf("\\n");
i--;
return 0;
Output
Program-13
AIM- To print input elements using 1D array
Source Code
#include <stdio.h>
int main()
{
int size;
printf("Enter the size of the array: ");
scanf("%d", &size);
int array[size];
printf("Enter %d values for the array:\n", size);
for (int i = 0; i < size; i++) {
scanf("%d", &array[i]);
}
printf("\nArray elements are:\n");
for (int i = 0; i < size; i++) {
printf("%d ", array[i]);
}
printf("\n");
return 0;
}
Output
Program-14
AIM- To print input elements using 2D array
Source Code
#include <stdio.h>
int main()
scanf("%d", &rows);
scanf("%d", &cols);
int array[rows][cols];
scanf("%d", &array[i][j]);
}}
printf("\n");
}
return 0;
Output
Program-15
AIM- To print the sum of all array elements
Source Code
#include <stdio.h>
int main()
int size;
int sum = 0;
scanf("%d", &size);
int array[size];
scanf("%d", &array[i]);
sum += array[i];
return 0;
}
Output
Program-16
AIM- To add two matrix
Source Code
#include <stdio.h>
int main()
scanf("%d", &matrix1[i][j]);
scanf("%d", &matrix2[i][j]);
printf("\n");
return 0;
Output
Program-17
AIM- To read and print a string
Source Code
#include <stdio.h>
int main()
char str[100];
return 0;
Output
Program-18
AIM- To find length of a string
Source Code
#include <stdio.h>
#include <string.h>
int main()
char Str[1000];
int i;
scanf("%s", Str);
return 0;
Output
Program-19
AIM- To concatenate two strings
Source Code
#include <stdio.h>
int main()
int length, j;
length = 0;
++length;
s1[length] = s2[j];
s1[length] = '\0';
puts(s1);
return 0;
Output
Program-20
AIM- To compare two strings
Source Code
#include <stdio.h>
#include<string.h>
int main()
{
char str1[20];
char str2[20];
int value;
printf("Enter the first string : ");
scanf("%s",str1);
printf("Enter the second string : ");
scanf("%s",str2);
value=strcmp(str1,str2);
if(value==0)
printf("strings are same");
else
printf("strings are not same");
return 0;
}
Output
Program-21
AIM- To find square root of a given number
Source Code
#include <math.h>
#include <stdio.h>
int main()
scanf("%lf", &number);
squareRoot = sqrt(number);
return 0;
Output
Program-22
AIM- To calculate the sum of two numbers using functions
Source Code
#include <stdio.h>
int main()
return 0;
Output
Program-23
Source Code
#include <stdio.h>
int main()
int x, y;
scanf("%d", &x);
scanf("%d", &y);
int temp = x;
x = y;
y = temp;
return 0;
Output
Program-24
AIM- To swap two numbers using call by reference
Source Code
#include <stdio.h>
int main()
swap(&num1, &num2);
return 0;
int temp;
temp = *num1;
*num1= *num2;
*num2= temp;
Output
Program-25
AIM- To find the factorial of a number using functions
Source Code
#include <stdio.h>
int fact(int);
void main()
{
int no,factorial;
printf("Enter a number: \n");
scanf("%d",&no);
factorial=fact(no);
printf("The Factorial of %d is %d\n",no,factorial);
}
int fact(int n)
{
int i,f=1;
for(i=1;i<=n;i++)
{
f=f*i;
}
return f;
}
Output
Program-26
AIM- To reverse a number using functions
Source Code
#include <stdio.h>
int reversedNum = 0;
return reversedNum;
int main() {
scanf("%d", &number);
reversedNumber = reverseNumber(number);
return 0;
}
Output
Program-27
AIM- To check a number is palindrome or not using functions
Source Code
#include <stdio.h>
num /= 10;
int main() {
int number;
scanf("%d", &number);
return 0;
}
Output
Program-28
AIM- To find maximum value in an array using pointer
Source Code
#include <stdio.h>
int main()
{
long array[100], *maximum, size, c, location = 1;
printf("Enter the number of elements in array\n");
scanf("%ld", &size);
printf("Enter %ld integers\n", size);
for ( c = 0 ; c < size ; c++ )
scanf("%ld", &array[c]);
maximum = array;
*maximum = *array;
for (c = 1; c < size; c++)
{
if (*(array+c) > *maximum)
{
*maximum = *(array+c);
location = c+1;
}
}
printf("Maximum element is present at location number %ld and it's value is %ld.\n",
location, *maximum);
return 0;
}
Output
Program-29
AIM- To generate the Fibonacci series
Source Code
#include <stdio.h>
void generateFibonacci(int n)
int a = 0;
int b = 1;
int i;
int temp = a;
a = b;
b = temp + b;
printf("\n");
int main() {
int n;
scanf("%d", &n);
generateFibonacci(n);
return 0;
Output
Program-30
AIM- To find Ackermann function
Source Code
#include <stdio.h>
if (m == 0) {
return n + 1;
} else if (n == 0) {
} else {
int main() {
int m, n;
return 0;
}
Output