c_practicale
c_practicale
PRACTICAL MANUAL
Submitted By
[MEEL PRAMILA]
1ST SEMESTER
DATE OF SUBMISSION:
➢ Meet the needs of users within an organizational and societal context through the
selection, creation, application, integration, and administration of computing
technologies.
➢ Apply concepts, probability, statistics, mathematics, through calculus (differential and
integral), numerical methods and sciences including applications appropriate in the field
of computing problems.
➢ Use algorithms, data structures, database management, software design, concepts of
programming languages and computer organization and architecture in the field of
computer applications.
COURSE OUTCOMES (COs)
10
11
12
1.write a program to that perform as calculator (addition,
multiplication,divison,subtraction)
Code:
//write a program to that perform as calculator(addition,multiplication
,divison,subtraction)
#include <stdio.h>
int main()
int n1,n2,addition,sub,multy,divison;
addition=n1 + n2;
sub = n1 - n2;
multy = n1*n2;
divison = n1 / n2;
printf("addtion= %d\n",addition);
printf("subtraction= %d\n",sub);
printf("multiplication= %d\n",multy);
printf("divison= %d\n",divison);
return 0;
}
Output:
Flowchart:
2. write a program to find area of triangle (a=h*b*.5)
Code:
//write a program to find area of triangle (a=h*b*.5)
#include <stdio.h>
int main ()
float b1, h1 , a1 ;
scanf("%f", &b1);
scanf("%f" , &h1);
a1 =0.5*b1*h1;
return 0;
}
output:
Flowchart:
3. write a program to calculate simple intrest(i=(p*r*n)/100)
Code:
//write a program to calculate simple intrest(i=(p*r*n)/100)
#include <stdio.h>
int main()
scanf("%f", &p1);
scanf("%f", &rate);
scanf("%f", &time);
return 0;
}
Output:
Flowchat:
4. write a program to interchange two numbers
Code:
//write a program to interchange two numbers
#include <stdio.h>
int main();
int n1,n2,temp;
scanf("%d", &n1);
scanf("%d", &n2);
temp=n1;
n1=n2;
n2=temp;
printf("after swapping:\n");
return 0;
}
Output:
flowchart:
5. write a c program to enter a distance in ti kilometer and
convert in to meter ,feet,inches and centimeter
Code:
//write a c program to enter a distance in ti kilometer and convert in to meter
,feet,inches and centimeter
#include <stdio.h>
int main()
scanf("%f", &km);
meters = km * 1000;
cm = meters * 100;
return 0;
}
Output:
Flowchart:
6. //write a program to compute fahrenheit from
centigrade (f=1.8*c+32)
Code:
//write a program to compute fahrenheit from centigrade (f=1.8*c+32)
#include <stdio.h>
int main()
scanf("%f", &n1);
f1 = 1.8 * n1 + 32;
return 0;
Output:
Flowchart:
7.Write a C program to find that the accepted number is
Negative, Positive or Zero
Code:
//Write a C program to find that the accepted number is Negative, Positive or Zero
#include <stdio.h>
int main()
int n1;
scanf("%d", &n1);
if (n1 > 0)
} else
return 0;
}
Output:
Flowchart:
8. Write a program to read marks of a student from
keyboard whether the student is pass or fail(using if else)
Code:
/*Write a program to read marks of a student from keyboard whether the student is
pass or fail(using if else)*/
#include <stdio.h>
int main()
int marks;
scanf("%d", &marks);
else
return 0;
}
Output:
Flowchart:
9. Write a program to read three numbers from keyboard
and find out maximum out of these three.(nested if else)
Code:
/*Write a program to read three numbers from keyboard and find out maximum out of
these three.(nested if else)*/
#include <stdio.h>
int main()
scanf("%d", &n1);
scanf("%d", &n2);
scanf("%d", &n3);
}
else
else
else
return 0;
}
Output:
Flowchart:
10. Write a C program to check whether the entered
character is capital, small letter, digit or any special
character
Code:
/*Write a C program to check whether the entered character is capital, small letter,
digit or any special character*/
#include <stdio.h>
int main()
char ch;
scanf("%d", &ch);
else
return 0;
Output:
Flowchart:
11. Write a program to read marks from keyboard and your
program should display equivalent grade according to
following table(if else ladder).
Code:
/*Write a program to read marks from keyboard and your program should display
equivalent grade according to following table(if else ladder)*/
#include <stdio.h>
int main()
int marks;
scanf("%d", &marks);
printf("Grade: Distinction\n");
{
printf("Grade: Second Class\n");
printf("Grade: Fail\n");
else
return 0;
}
12. Write a c program to prepare pay slip using following
data.Da = 10% of basic, Hra = 7.50% of basic, Ma = 300, Pf =
12.50% of basic, Gross = basic + Da + Hra + Ma, Nt = Gross –
Pf.*/
Code:
/*Write a c program to prepare pay slip using following data.Da = 10% of basic, Hra =
7.50% of basic, Ma = 300, Pf = 12.50% of basic, Gross = basic + Da + Hra + Ma, Nt = Gross
– Pf.*/
#include <stdio.h>
int main()
scanf("%f", &basic);
da = 0.10* basic;
pf = 0.125 * basic;
return 0;
Output:
13. Write a C program to read no 1 to 7 and print relatively
day Sunday to Saturday.
Code:
//Write a C program to read no 1 to 7 and print relatively day Sunday to Saturday.
#include <stdio.h>
int main()
int day;
scanf("%d", &day);
switch (day)
case 1:
printf("Sunday");
break;
case 2:
printf("Monday");
break;
case 3:
printf("Tuesday");
break;
case 4:
printf("Wednesday");
break;
case 5:
printf("Thursday");
break;
case 6:
printf("Friday");
break;
case 7:
printf("Saturday");
break;
default:
return 0;
Output:
14. Write a C program to find out the Maximum and
Minimum number from given 10 numbers
Code:
//Write a C program to find out the Maximum and Minimum number from given 10
numbers
#include <stdio.h>
int main()
printf("Enter 10 numbers:\n");
scanf("%d", &n1[i]);
max = n1[i];
{
min = n1[i];
return 0;
Output:
15. Write a C program to find factorial of a given number.
Code:
//Write a C program to find factorial of a given number.
#include <stdio.h>
int main()
int n, i;
long fact = 1;
scanf("%d", &n);
if (n < 0)
else
fact *= i;
}
return 0;
Output:
16. Write a program to reverse a number.
code:
//Write a program to reverse a number.
#include <stdio.h>
int main()
scanf("%d", &n1);
while (n1 != 0)
n3 = n1 % 10;
n2 = n2 * 10 + n3;
n1 /= 10;
return 0;
}
Output:
17. Write a program to generate first n number of Fibonacci
series
Code:
//Write a program to generate first n number of Fibonacci series
#include <stdio.h>
int main()
int n, i;
printf("Enter number");
scanf("%d", &n);
if (n <= 0)
else if (n == 1)
else
first = second;
second = next;
printf("\n");
return 0;
Output:
18. Write a program to calculate average and total of 5
students for 3 subjects (use nested for loops)*/
Code:
/*Write a program to calculate average and total of 5 students for 3 subjects (use nested
for loops)*/
#include <stdio.h>
int main()
int i, j;
int s1 = 5;
int sub = 3;
total = 0;
scanf("%f", &marks);
total += marks;
return 0;
Output:
19. Read five persons height and weight and count the
number of person having height greater than 170 and weight
less than 50
Code:
/*Read five persons height and weight and count the number of person having height
greater than 170 and weight less than 50*/
#include <stdio.h>
int main()
int i, count;
scanf("%f", &h1);
scanf("%f", &w1);
count++;
}
printf("Number of persons with height greater than 170 cm and weight less than 50
kg: %d\n", count);
return 0;
Output:
20. Write a program to check whether the given number is
prime or not.
Code:
//Write a program to check whether the given number is prime or not.
#include <stdio.h>
int main()
int num, i;
scanf("%d", &num);
if (num < 2)
return 0;
if (num % i == 0)
return 0;
}
printf("%d is a prime number.\n", num);
return 0;
Output:
21. Write a program to evaluate the series 1^2+2^2+3
^2+……+n^2
Code:
//Write a program to evaluate the series 1^2+2^2+3^2+……+n^2
#include <stdio.h>
int main()
int n, i;
int sum;
scanf("%d", &n);
sum += i * i;
printf("The sum of the series 1^2 + 2^2 + ... + %d^2 is: %d\n", n, sum);
return 0;
}
Output:
22. Write a C program to find 1+1/2! +1/3! +1/4! +. ..... +1/n!
Code:
//Write a C program to find 1+1/2! +1/3! +1/4! +. ..... +1/n!
#include <stdio.h>
int main() {
int n;
double sum = 1;
double factorial = 1;
scanf("%d", &n);
int i;
factorial *= i;
return 0;
}
Output:
23. Write a program to print following patterns :
Code:
//Write a program to print following patterns :
#include <stdio.h>
int main()
int i, j, space;
printf("Pattern 1\n");
printf("*");
printf("\n");
printf("Pattern 2\n");
printf(" ");
printf("* ");
printf("\n");
printf("Pattern 3\n");
printf("*");
printf("\n");
return 0;
}
Output:
24. Write a program to print following patterns
Code:
//Write a program to print following patterns
#include <stdio.h>
int main()
int i, j;
printf("pattern 1:\n");
printf("%d", j);
printf("\n");
printf("\npattern 2:\n");
printf("%d", j);
printf("\n");
}
printf("\npattern 3:\n");
printf("%d", i);
printf("\n");
printf("\npattern 4:\n");
printf("%d", i);
printf("\n");
return 0;
}
Output:
25. Write a program to print following patterns
Code:
//Write a program to print following patterns
#include <stdio.h>
int main()
int i, j;
printf("pattern 1:\n");
printf("\n");
printf("\npattern 2:\n");
}
printf("\n");
return 0;
Output: