C Programming Lab Manual Solutions with Source Code(in Comments)

preview_player
Показать описание
INTRODUCTION & FUNDAMENTALS OF C:
Write a program to Print Hello World 0:10
Write a program to take a variable print it. 0:59
Write a program to take user input and print it
Write a program to take different kind of data types value and print it. 2:40
Write a program to find size of variables. 3:37
OPERATORS AND EXPRESSIONS, DATA INPUT AND OUTPUT:
Write a program to add two number 5:40
Write a program to calculate Simple interest of a user given amount. 7:12
Write a program to demonstrate working of arithmetic operators. 13:26
Write a program to demonstrate working of Unary operators. 16:45
Write a program to print remainder of a division of two user given input. 20:11
CONDITIONAL STATEMENTS, LOOPS AND FUNCTIONS:
Write a program to check the largest number between two given number 21:46
Write a program to check the largest number between three given number 24:02
Write a program to convert Fahrenheit to Celsius 28:00
Write a C program to add first 10 number using while loop 32:20
Write a program in C to print sum of a user given numbers digits. 40:50
Write a program in C to print reverse of a user given input 55:28
Accept the salary of an employee from the user. 59:53
Calculate the gross salary on the following basis:
Basic HRA DA
1 - 4000 10% 50%
4001 - 8000 20% 60%
8001 - 12000 25% 70%
12000 and
above
30% 80%
Write a program to Display all prime numbers between 50 and 150. 1:08:45
Write a program in C to print following patterns:
(A) 1:16:55
*
* *
* * *
* * * *
* * * * *
AJU-BCA Syllabus w.e.f Batch 2020
30
(B) 1:31:55
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Write a program to swap the values of two numbers using call by value 1:41:28
Write a program to print Fibonacci series using function
1:47:35
PROGRAM STRUCTURE, PREPROCESSOR, ARRAYS
Write a program in C to create an array and print its values 1:59:10
Write a program to find largest number of an array
2:08:02
Write a program to find smallest number of an array.
2:15:20
Write a program in C to swap smallest and largest number of an array. 2:18:55
Write a program to sort an array inputs. 2:32:33
POINTERS, STRUCTURES AND UNIONS, FILE HANDLING
Write a program in C to swap two number using call by reference 2:39:20
Write a program in C to Create a structure Student to store name, roll, marks of different data types. 2:43:10
Write a program in C to create Union Employee to store employee details. 2:54:55
Write a C program to read name and marks of n number of students and store them in a file..
Write a C program to read name and marks of n number of students from and store them in a file. If
the file previously exits, add the information to the file.
2:56:20
Рекомендации по теме
Комментарии
Автор

0:10 Print Hello World

#include <stdio.h>

int main() {

printf("Hello world");

return 0;
}



0:59 take a variable print it


#include <stdio.h>

int main() {
int a = 10;

printf("%d", a);

return 0;
}


take user input and print it

#include <stdio.h>

int main() {
int a ;

printf("Enter the no.");
scanf("%d", &a);
printf("%d", a);
return 0;
}



2:40 different kind of data types value and print it

#include <stdio.h>

int main() {
int a = 10;
float b = 12.6;
char c = 'a';
printf("%d %.2f %c", a, b, c);

return 0;
}


3:37 find size of variables

#include <stdio.h>

int main() {
int a = 10;
float b = 12.6;
char c = 'a';
printf("%d %d %d", sizeof(a), sizeof(b), sizeof(c));

return 0;
}


5:40 add two number


#include <stdio.h>

int main() {
int a = 10, b=20, c;
c=a+b;
printf("%d", c);

return 0;
}

7:12 Simple interest of a user given amount.

#include <stdio.h>

int main() {
float p, r, t, si;

printf("Enter Amount: ");
scanf("%f", &p);
printf("Enter Rate: ");
scanf("%f", &r);
printf("Enter Time: ");
scanf("%f", &t);

si = (p*r*t)/100;
printf("Simple Interest is %.2f", si);

return 0;
}


13:26 working of arithmetic operators.

#include <stdio.h>
int main()
{
int a = 9, b = 4, c;

c = a+b;
printf("a+b = %d \n", c);
c = a-b;
printf("a-b = %d \n", c);
c = a*b;
printf("a*b = %d \n", c);
c = a/b;
printf("a/b = %d \n", c);
c = a%b;
printf("Remainder when a divided by b = %d \n", c);

return 0;
}


16:45 working of Unary operators.

#include <stdio.h>

int main()
{
int a = 20, b, c, d;

b=-a;
printf("%d ", b);

a++;
b--;
printf("%d %d", a, b);

return 0;
}



20:11 remainder of a division of two user given input.

#include <stdio.h>

int main()
{
int a, b, rem;

printf("Enter the First no. ", b);
scanf("%d", &a);
printf("Enter the Second no. ", b);
scanf("%d", &b);

rem = a%b;
printf("Remainder is %d", rem);

return 0;
}




21:46 WAP to check the largest number between two given number

#include <stdio.h>

int main()
{
int a=11, b=20;

if(a>b){
printf("A is greater");
}
else{
printf("B is greater");
}

return 0;
}



24:02 WAP to check the largest number between three given number

#include <stdio.h>

int main()
{
int a=11, b=20, c=40;

if(a>b && a>c){
printf("A is greater");
}
if(b>a && b>c){
printf("B is greater");
}
else{
printf("C is greater");
}

return 0;
}



28:00 WAP to convert Fahrenheit to Celsius

#include <stdio.h>

int main()
{
float c, f;

printf("Enter temp in C : ");
scanf("%f", &c);

f=(9*c/5)+32;
printf("%.2f", f);


return 0;
}



32:20 Write a C program to add first 10 number using while loop


#include <stdio.h>

int main()
{
int a=1, sum=0;

while(a<11){
sum=sum+a;
a++;
}
printf("Sum is %d", sum);

return 0;
}



40:50 WAP in C to print sum of a user given numbers digits.

#include <stdio.h>

int main()
{
int a, b, sum=0;

printf("Enter the number: ");
scanf("%d", &a);

while(a!=0){
b=a%10;
a=a/10;
sum=sum+b;
}
printf("Sum is %d", sum);

return 0;
}



55:28 reverse of a user given input


#include <stdio.h>

int main()
{
int a, b, rev=0;

printf("Enter the number: ");
scanf("%d", &a);

while(a!=0){
b=a%10;
a=a/10;
rev=rev*10+b;
}
printf("reverse is %d", rev);

return 0;
}



59:53 Accept the salary of an employee from the user.

#include <stdio.h>

int main()
{
float b, t;

printf("Enter Basic Amount: ");
scanf("%f", &b);

if(b>12000){
t=b + 0.3*b + 0.8*b;
}
else if(b>8000 && b<=12000){
t=b + 0.25*b + 0.7*b;
}
else if(b>4000 && b<=8000){
t=b + 0.2*b + 0.6*b;
}
else if(b>1 && b<=4000){
t=b + 0.1*b + 0.5*b;
}
printf("reverse is %.2f", t);

return 0;
}



1:08:45 all prime numbers between 50 and 150.

#include <stdio.h>

int main()
{
for(int i=51;i<150;i++){
int prime = 1;
for(int j=2;j<i;j++){
if(i%j==0){
prime=0;
}
}
if(prime){
printf("\n%d", i);
}
}

return 0;
}



WAP in C to print following patterns:
1:16:55 Pattern(A)

#include <stdio.h>

int main()
{
int n = 5;
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
printf("* ");
}
printf("\n");
}

return 0;
}



1:31:55 Pattern(B)

#include <stdio.h>

int main()
{
for(int i=5;i!=0;i--){
for(int j=1;j<=i;j++){
printf("%d ", j);
}
printf("\n");
}

return 0;
}



1:41:28 Swap the values of two numbers using call by value

#include <stdio.h>

int main()
{
int a = 10, b=20;

swap(a, b);
return 0;
}

void swap(int a, int b){
int temp;
temp = a;
a=b;
b=temp;
printf("After Swap a and b is %d %d", a, b);
}


1:47:35 Fibonacci series using function

#include <stdio.h>

int main()
{
int n = 5;

fib(n);
return 0;
}

void fib(int n){

int a = 0, b = 1, c;
while(n--){
printf("%d ", a);
c=a+b;
a=b;
b=c;
}
}


1:59:10 create an array and print its values

#include <stdio.h>

int main() {

int n;
printf("Enter the No. of elements to store in array: ");
scanf("%d", &n);

int a[n];
printf("Enter the Elements: ");
for(int i=0;i<n;i++){
scanf("%d", &a[i]);
}

printf("Elements of Array are :");
for(int i=0;i<n;i++){
printf(" %d", a[i]);
}


return 0;
}


2:08:02 find largest number of an array

#include <stdio.h>

int main() {

int n;
printf("Enter the No. of elements to store in array: ");
scanf("%d", &n);

int a[n];

printf("Enter the Elements: ");
for(int i=0;i<n;i++){
scanf("%d", &a[i]);
}

int max;
printf("Largest element is :");
for(int i=0;i<n;i++){
if(i==0){
max=a[i];
}
else if(a[i]>max){
max=a[i];
}
}
printf(" %d", max);

return 0;
}

devsharanmahato
visit shbcf.ru