Problem Solving Lab
Problem Solving Lab
Solving
Lab
Manual
2023
Techno College
Of Engineering
Agartala
Problem Solving Lab Manual 2023
Table of Contents
Experiment No: 01................................................................................................................................................................ 4
Aim:WAP to print “ Hello world! “ in C programming ................................................................................................ 4
Experiment No: 02................................................................................................................................................................ 4
Aim: WAP to print an integer using C programming (Entered by the user).................................................................... 4
Experiment No: 03................................................................................................................................................................ 5
Aim: WAP to Add two integers using C programming ................................................................................................... 5
Experiment No: 04................................................................................................................................................................ 5
Aim: WAP to Multiply two Floating – Point Numbers using C programming ............................................................... 5
Experiment No: 05................................................................................................................................................................ 6
Aim: WAP to find ASCII value of a character using C programming ............................................................................ 6
Experiment No: 06................................................................................................................................................................ 6
Aim: WAP to Compute Quotient and Remainder using C programming........................................................................ 7
Experiment No: 07................................................................................................................................................................ 7
Aim: WAP to find the size of int , float, double and char using C programming ............................................................ 7
Experiment No: 08................................................................................................................................................................ 8
Aim: WAP to Swap two numbers using C programming ................................................................................................ 8
Experiment No: 09................................................................................................................................................................ 9
Aim: WAP to Check Whether a number is even or odd ............................................................................................ 10
Experiment No: 10.............................................................................................................................................................. 10
Aim: WAP to Check Whether a Character is Vowel or Consonant ............................................................................... 10
Experiment No: 11.............................................................................................................................................................. 11
Aim: WAP to Find the largest number among three numbers ....................................................................................... 11
Experiment No: 12.............................................................................................................................................................. 11
Aim: WAP to check a year is leap year or not .............................................................................................................. 11
Experiment No: 13.............................................................................................................................................................. 12
Aim: WAP to check whether a Character is an Alphabet or not .................................................................................... 12
Experiment No: 14.............................................................................................................................................................. 13
Aim: WAP to calculate the sum of natural numbers ...................................................................................................... 13
Experiment No: 15.............................................................................................................................................................. 14
Aim: WAP to find factorial of a number....................................................................................................................... 14
Experiment No: 16.............................................................................................................................................................. 15
Aim: WAP to Generate Multiplication Table. ............................................................................................................... 15
Experiment No: 17.............................................................................................................................................................. 16
Page 1 of 37
Problem Solving Lab Manual 2023
Aim: WAP to Display fibonacci Sequence .................................................................................................................... 16
Experiment No: 18.............................................................................................................................................................. 16
Aim: WAP to find GCD of two numbers ....................................................................................................................... 16
Experiment No: 19.............................................................................................................................................................. 17
Aim: WAP to find LCM of two numbers ...................................................................................................................... 17
Experiment No: 20.............................................................................................................................................................. 18
Aim: WAP to Display Characters from A to Z using Loop ........................................................................................... 18
Experiment No: 21.............................................................................................................................................................. 18
Aim: WAP to Reverse a number .................................................................................................................................. 18
Experiment No: 22.............................................................................................................................................................. 19
Aim: WAP to check whether a number is palindrome or not ........................................................................................ 19
Experiment No: 23.............................................................................................................................................................. 20
Aim: WAP to check whether a number is prime or not ................................................................................................. 20
Experiment No: 24.............................................................................................................................................................. 21
Aim: WAP to display prime numbers between two intervals ........................................................................................ 21
Experiment No: 25.............................................................................................................................................................. 22
Aim: WAP to display factors of a number ..................................................................................................................... 22
Experiment No: 26.............................................................................................................................................................. 23
Aim: WAP to display prime numbers between intervals using function ....................................................................... 23
Experiment No: 27.............................................................................................................................................................. 24
Aim: WAP to check whether a number can be expressed as sum of two prime numbers ............................................. 24
Experiment No: 28.............................................................................................................................................................. 26
Aim: WAP to find the sum of natural numbers using recursion ................................................................................... 26
Experiment No: 29.............................................................................................................................................................. 27
Aim: WAP to convert Binary number to Decimal and vice-versa ................................................................................. 27
Experiment No: 30.............................................................................................................................................................. 27
Aim: WAP to convert Octal number to Decimal and vice-versa ................................................................................... 27
Experiment No: 31.............................................................................................................................................................. 27
Aim: WAP to calculate average using array .................................................................................................................. 27
Experiment No: 32.............................................................................................................................................................. 28
Aim: WAP to find the largest element in a array ........................................................................................................... 28
Experiment No: 33.............................................................................................................................................................. 29
Aim: WAP to add two matrices using multi dimentional array .................................................................................... 29
Experiment No: 34.............................................................................................................................................................. 31
Page 2 of 37
Problem Solving Lab Manual 2023
Aim: WAP to find transpose of a matrix........................................................................................................................ 31
Experiment No: 35.............................................................................................................................................................. 32
Aim: WAP to multiply two matrices using multi-dimensional arrays ........................................................................... 32
Experiment No: 36.............................................................................................................................................................. 33
Aim: WAP to find the length of a string ....................................................................................................................... 33
Experiment No: 37.............................................................................................................................................................. 34
Aim: WAP to concatenate two strings ........................................................................................................................... 34
Experiment No: 38.............................................................................................................................................................. 34
Aim: WAP to copy string without using strcpy() .......................................................................................................... 34
Experiment No: 39.............................................................................................................................................................. 35
Aim: WAP to print pyramids and patterns ..................................................................................................................... 35
Experiment No: 40.............................................................................................................................................................. 35
Aim: WAP to find the square root using python programming ..................................................................................... 35
Experiment No: 41.............................................................................................................................................................. 36
Aim: WAP to convert kilometers to miles using python ............................................................................................... 36
Experiment No: 42.............................................................................................................................................................. 36
Aim: WAP to convert celsius to fahrenheit using python .............................................................................................. 36
Experiment No: 43.............................................................................................................................................................. 36
Aim: WAP to check if a number is positive, negative or zero ....................................................................................... 36
Experiment No: 44.............................................................................................................................................................. 36
Aim: WAP to print all prime numbers in an interval using python .............................................................................. 36
Experiment No: 45.............................................................................................................................................................. 36
Aim: WAP to make a simple calculator using python ................................................................................................... 36
Experiment No: 46.............................................................................................................................................................. 36
Aim: WAP to display calender using python ................................................................................................................. 36
Experiment No: 47.............................................................................................................................................................. 36
Aim: WAP to find sum of natural numbers using recursion .......................................................................................... 36
Experiment No: 48.............................................................................................................................................................. 36
Aim: WAP to add two matrices using python............................................................................................................... 36
Experiment No: 49.............................................................................................................................................................. 36
Aim: WAP to sort words in alphabetic order using python ........................................................................................... 36
Experiment No: 50.............................................................................................................................................................. 36
Aim: WAP to check whether a string is palindrome or not .......................................................................................... 36
Page 3 of 37
Problem Solving Lab Manual 2023
Experiment No: 01
int main()
printf("Hello, World!");
return 0;
Output:
Hello, World!
Experiment No: 02
Aim: WAP to print an integer using C programming (Entered by the user)
Program:
#include<stdio.h>
int number;
scanf("%d", &number);
return 0;
Page 4 of 37
Problem Solving Lab Manual 2023
Output:
Enter an integer: 25
You entered: 25
Experiment No: 03
Aim: WAP to Add two integers using C programming
Program:
#include <stdio.h>
int main() {
return 0;
Output:
Experiment No: 04
Aim: WAP to multiply two Floating-point numbers using C programming
Program:
#include <stdio.h>
int main() {
double a, b, product;
Page 5 of 37
Problem Solving Lab Manual 2023
printf("Enter two numbers: ");
product = a * b;
return 0;
Output:
Experiment No: 05
Aim: WAP to find ASCII value of a character using C programming
Program:
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
return 0;
Output:
Enter a character: G
ASCII value of G = 71
Experiment No: 06
Page 6 of 37
Problem Solving Lab Manual 2023
int main() {
scanf("%d", ÷nd);
scanf("%d", &divisor);
return 0;
Output:
Enter dividend: 25
Enter divisor: 4
Quotient = 6
Remainder = 1
Experiment No: 07
Aim: WAP to find the size of int , float, double and char using C programming
Program:
#include<stdio.h>
int main() {
intintType;
floatfloatType;
Page 7 of 37
Problem Solving Lab Manual 2023
doubledoubleType;
charcharType;
return 0;
Output:
Experiment No: 08
Aim: WAP to Swap two numbers using C programming
Program:
#include<stdio.h>
int main() {
scanf("%lf", &first);
scanf("%lf", &second);
temp = first;
first = second;
second = temp;
Page 8 of 37
Problem Solving Lab Manual 2023
printf("\nAfter swapping, first number = %.2lf\n", first);
return 0;
Output:
Experiment No: 09
Aim: WAP to Check whether a number is even or odd
Program:
#include <stdio.h>
int main() {
intnum;
scanf("%d", &num);
if(num % 2 == 0)
else
return 0;
Page 9 of 37
Problem Solving Lab Manual 2023
Output:
Enter an integer: -7
-7 is odd.
Experiment No: 10
Aim: WAP to Check whether a Character is vowel or consonant
Program:
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
if (lowercase_vowel || uppercase_vowel)
else
return 0;
Output:
Enter an alphabet: G
G is a consonant.
Page 10 of 37
Problem Solving Lab Manual 2023
Experiment No: 11
Aim: WAP to find the largest number among three numbers
Program:
#include <stdio.h>
int main() {
return 0;
Output:
Experiment No: 12
Aim: WAP to check a year is leap year or not
Program:
#include <stdio.h>
int main() {
int year;
Page 11 of 37
Problem Solving Lab Manual 2023
printf("Enter a year: ");
scanf("%d", &year);
if (year % 400 == 0) {
else if (year % 4 == 0) {
else {
return 0;
Output:
Output 1
Output 2
Experiment No: 13
Aim: WAP to check whether a character is an Alphabet or not
Program:
Page 12 of 37
Problem Solving Lab Manual 2023
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
else
return 0;
Output:
Enter a character: *
* is not an alphabet
Experiment No: 14
Aim: WAP to calculate the sum of natural numbers
Program:
#include <stdio.h>
int main() {
int n, i, sum = 0;
scanf("%d", &n);
i = 1;
while (i <= n) {
sum += i;
Page 13 of 37
Problem Solving Lab Manual 2023
++i;
return 0;
Output:
Experiment No: 15
Aim: WAP to find factorial of a number
Program:
#include <stdio.h>
int main() {
int n, i;
scanf("%d", &n);
if (n < 0)
else {
fact *= i;
return 0;
Page 14 of 37
Problem Solving Lab Manual 2023
Output:
Enter an integer: 10
Factorial of 10 = 3628800
Experiment No: 16
Aim: WAP to Generate Multiplication Table
Program:
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
return 0;
Output:
Enter an integer: 9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90
Page 15 of 37
Problem Solving Lab Manual 2023
Experiment No: 17
Aim: WAP to Display Fibonacci Sequence
Program:
#include <stdio.h>
int main() {
int i, n;
int t1 = 0, t2 = 1;
intnextTerm = t1 + t2;
scanf("%d", &n);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
return 0;
Output:
Experiment No: 18
Aim: WAP to find GCD of two numbers
Program:
#include <stdio.h>
int main()
Page 16 of 37
Problem Solving Lab Manual 2023
int n1, n2;
scanf("%d %d",&n1,&n2);
while(n1!=n2)
n1 -= n2;
else
n2 -= n1;
printf("GCD = %d",n1);
return 0;
Output:
Experiment No: 19
Aim: WAP to find LCM of two numbers
Program:
#include <stdio.h>
int main() {
while (1) {
Page 17 of 37
Problem Solving Lab Manual 2023
printf("The LCM of %d and %d is %d.", n1, n2, max);
break;
++max;
return 0;
Output:
Experiment No: 20
Aim: WAP to Display Characters from A to Z using loop
Program:
#include <stdio.h>
int main() {
char c;
return 0;
Output:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Experiment No: 21
Aim: WAP to Reverse a number
Program:
#include <stdio.h>
Page 18 of 37
Problem Solving Lab Manual 2023
int main() {
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
n /= 10;
return 0;
Output:
Experiment No: 22
Aim: WAP to check whether a number is palindrome or not
Program:
#include <stdio.h>
int main() {
scanf("%d", &n);
original = n;
while (n != 0) {
remainder = n % 10;
Page 19 of 37
Problem Solving Lab Manual 2023
n /= 10;
if (original == reversed)
else
return 0;
Output:
Experiment No: 23
Aim: WAP to check whether a number is prime or not
Program:
#include <stdio.h>
int main() {
int n, i, flag = 0;
scanf("%d", &n);
if (n == 0 || n == 1)
flag = 1;
if (n % i == 0) {
flag = 1;
break;
Page 20 of 37
Problem Solving Lab Manual 2023
if (flag == 0)
else
return 0;
Output:
Experiment No: 24
Aim: WAP to display prime numbers between two intervals
Program:
#include <stdio.h>
int main() {
flag = 0;
if (low <= 1) {
++low;
continue;
if (low % i == 0) {
Page 21 of 37
Problem Solving Lab Manual 2023
flag = 1;
break;
if (flag == 0)
++low;
return 0;
Output:
Experiment No: 25
Aim: WAP to display factors of a number
Program:
#include <stdio.h>
int main() {
intnum, i;
scanf("%d", &num);
if (num % i == 0) {
Page 22 of 37
Problem Solving Lab Manual 2023
}
return 0;
Output:
Experiment No: 26
Aim: WAP to display prime numbers between intervals using function
Program:
#include <stdio.h>
intcheckPrimeNumber(int n);
int main() {
n1 = n1 + n2;
n2 = n1 - n2;
n1 = n1 - n2;
flag =checkPrimeNumber(i);
if (flag == 1) {
Page 23 of 37
Problem Solving Lab Manual 2023
}
return 0;
intcheckPrimeNumber(int n) {
int j, flag = 1;
if (n % j == 0) {
flag = 0;
break;
return flag;
Output:
Experiment No: 27
Aim: WAP to check whether a number can be expressed as sum of two prime numbers
Program:
#include <stdio.h>
intcheckPrime(int n);
int main() {
int n, i, flag = 0;
scanf("%d", &n);
Page 24 of 37
Problem Solving Lab Manual 2023
if (checkPrime(i) == 1) {
if (checkPrime(n - i) == 1) {
flag = 1;
if (flag == 0)
return 0;
intcheckPrime(int n) {
int i, isPrime = 1;
if (n == 0 || n == 1) {
isPrime = 0;
else {
if(n % i == 0) {
isPrime = 0;
break;
returnisPrime;
Output:
Page 25 of 37
Problem Solving Lab Manual 2023
Experiment No: 28
Aim: WAP to sum of natural numbers using recursion
Program :
#include <stdio.h>
intaddNumbers(int n);
int main() {
intnum;
scanf("%d", &num);
return 0;
intaddNumbers(int n) {
if (n != 0)
else
return n;
Output:
Page 26 of 37
Problem Solving Lab Manual 2023
Experiment No: 29
Aim: WAP to check Armstrong Number
Program:
Output:
Experiment No: 30
Aim: WAP to Display Armstrong number between two intervals
Program:
Output:
Experiment No: 31
Aim: WAP to calculate average using array
Program:
#include <stdio.h>
int main() {
int n, i;
scanf("%d", &n);
scanf("%d", &n);
scanf("%f", &num[i]);
sum += num[i];
Page 27 of 37
Problem Solving Lab Manual 2023
}
avg = sum / n;
return 0;
Output:
Experiment No: 32
Aim: WAP to find the largest element in a array
Program:
#include <stdio.h>
int main() {
int n;
doublearr[100];
scanf("%d", &n);
scanf("%lf", &arr[i]);
if (arr[0] <arr[i]) {
arr[0] = arr[i];
Page 28 of 37
Problem Solving Lab Manual 2023
}
return 0;
Output:
Experiment No: 33
Aim: WAP to add two matrices using multi dimentional array
Program:
#include <stdio.h>
int main() {
scanf("%d", &r);
scanf("%d", &c);
scanf("%d", &a[i][j]);
Page 29 of 37
Problem Solving Lab Manual 2023
for (i = 0; i < r; ++i)
scanf("%d", &b[i][j]);
if (j == c - 1) {
printf("\n\n");
} }
return 0;
Output:
Page 30 of 37
Problem Solving Lab Manual 2023
Enter element b21: 5
Enter element b22: 6
Enter element b23: 3
10 8 6
Experiment No: 34
Aim: WAP to find transpose of a matrix
Program:
#include <stdio.h>
int main() {
scanf("%d", &a[i][j]);
if (j == c - 1)
printf("\n");
Page 31 of 37
Problem Solving Lab Manual 2023
for (int j = 0; j < c; ++j) {
transpose[j][i] = a[i][j];
if (j == r - 1)
printf("\n");
return 0;
Output:
Entered matrix:
1 4 0
-5 2 7
Experiment No: 35
Aim: WAP to find the length of a string
Program:
Page 32 of 37
Problem Solving Lab Manual 2023
#include <stdio.h>
int main() {
int i;
return 0;
Output:
Experiment No: 36
Aim: WAP to concatenate two string
Program:
#include <stdio.h>
int main() {
int length, j;
length = 0;
++length;
s1[length] = s2[j];
s1[length] = '\0';
puts(s1);
Page 33 of 37
Problem Solving Lab Manual 2023
return 0;
Output:
Experiment No: 37
Aim: WAP to copy string without using strcpy()
Program:
#include <stdio.h>
int main() {
s2[i] = s1[i];
s2[i] = '\0';
return 0;
Output:
Experiment No: 38
Aim: WAP to store information of student using structure
Program:
Page 34 of 37
Problem Solving Lab Manual 2023
Output:
Experiment No: 39
Aim: WAP to print pyramids and patterns
Program:
#include <stdio.h>
int main() {
int i, j, rows;
scanf("%d", &rows);
printf("* ");
printf("\n");
return 0;
Output:
*
* *
* * *
* * * *
* * * * *
Experiment No: 40
Aim: WAP to find the square root using python programming
Program:
num = 8
Page 35 of 37
Problem Solving Lab Manual 2023
num_sqrt = num ** 0.5
Output:
Experiment No: 41
Aim: WAP to convert kilometers to miles using python
Program:
conv_fac = 0.621371
Output:
Experiment No: 42
Aim: WAP to convert Celsius to Fahrenheit using python
Program:
Output:
Experiment No: 43
Aim: WAP to check if a number is positive ,negative or zero
Program:
Output:
Experiment No: 44
Aim: WAP to print all prime numbers in an interval using python
Program:
Page 36 of 37
Problem Solving Lab Manual 2023
Output:
Experiment No: 45
Aim: WAP to make a simple calculator using python
Program:
Output:
Experiment No: 46
Aim: WAP to display calendar using python
Program:
Output:
Experiment No: 47
Aim: WAP to find sum of natural numbers using recursion
Program:
Output:
Experiment No: 48
Aim: WAP to add two matrices using python
Program:
Output:
Experiment No: 49
Aim: WAP to sort words in alphabetic order using python
Program:
Output:
Experiment No: 50
Aim: WAP to check whether a string is palindrome or not
Program:
Output:
Page 37 of 37