0% found this document useful (0 votes)
38 views15 pages

C Programming Practical: Lokanthalli, Bhaktapur

The document contains C code to find the largest number among three numbers using conditional operators. It takes input of three integers a, b, c and uses conditional operator expressions to check if a is greater than b and b is greater than c, assigning the largest to variable x. It then prints x as the greatest number.

Uploaded by

Jeevan Regmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views15 pages

C Programming Practical: Lokanthalli, Bhaktapur

The document contains C code to find the largest number among three numbers using conditional operators. It takes input of three integers a, b, c and uses conditional operator expressions to check if a is greater than b and b is greater than c, assigning the largest to variable x. It then prints x as the greatest number.

Uploaded by

Jeevan Regmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

LOKANTHALLI, BHAKTAPUR

C Programming Practical

SUBMITTED BY: SUBMITTED TO:


Sudhan regmi
Write a C program to find area of circle.
Algorithm
Step 1: start
Step 2: Declare integer 'a' and float 'area' and 'pi'
Step 3: Define value of a
Step 4: Area values of 'a' and 'pi'
Step 5: Store O/P of step 4 to area
Step 6: print area
Step 7: Stop

Flow chart

Start

Get integer a

Area=pi*r*r

Print area

End
// Write a C program to find area of circle.
//area of circle//
#include<stdio.h>
#include<conio.h>
int main(){
float r,PI,Area;
printf("Enter the radius :");
scanf("%f",&r);
PI=3.14;
Area= PI*r*r;
printf("Area of circle : %f",Area);
getch();
return 0;
}

Output result
Write a C program to find simple interest.
Algorithm
Step 1: Start
Step 2: Declare integer 'x', 'y' and 'z'
Step 3: Define value of 'x', 'y' and 'z' & float 'interest'
Step 4: Simple interest values if 'x', 'y', and 'z'
Step 5: Store the O/P value of step 4 to simple interest
Step 6: Print simple interest
Step 7: Stop

Flow chart

Start

Get integer x, y, z

Simple interest= (x*y*z)/100

Print Simple interest

End
//Write a C program to find simple interest.

// write a program to find a simple intrest //


#include<stdio.h>
#include<conio.h>
int main()
{
float principle, time, rate, SI;
printf("Enter principle (amount): ");
scanf("%f", &principle);
printf("Enter time: ");
scanf("%f", &time);
printf("Enter rate: ");
scanf("%f", &rate);
SI = (principle * time * rate) / 100;
printf("Simple Interest = %f", SI);
getch();

return 0;
}

Output result
Check the difference between signed int and unsigned int using a
program
Algorithm
Step 1: Start
Step 2: Declare signed int 'a' and unsigned int 'b'
Step 3: Define the values of 'a' and 'b'
Step 4: Store O/P of step 3 to 'a' and 'b'
Step 5: Add the values of 'a' and 'b'
Step 6: Store O/P of step 5 to 'sum'
Step 7: Print 'sum'
Step 8: Stop

Flow chart

Start

Get a and b

Sum= a + b

Print sum

End
// Check the difference between signed int and unsigned int using a
program
//check the differenc between signed and unsigned int//
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
printf("Enter the signed number :");
scanf("%d",&a);
unsigned int b;
printf("Enter the unsigned number :");
scanf("%u",&b);
printf("\nEnter singned number:%d",a);
printf("\nEnter unsigned number:%a\n",b);
int sum=a+b;
printf("sum = %d",sum);
getch();
return 0;
}
Output result
Implement integer input formatting in c
Algorithm
Step 1: Start
Step 2: Declare integer 'a'
Step 3: Define the value and use at least 3 spaces of 'a'
Step 4: Store O/P of step 3
Step 5: Print the integer
Step 6: End

Flow chart Start

Get integer a

Print remaining of a

End
Implement integer input formatting in c
// implement integer input formatting in c //
#include <stdio.h>
#include <conio.h>
main()
{
int a;
printf("Enter the integer :");
scanf("%5d",&a);
printf("Your value = %d",a);
getch();

Output result
Write a C program to swap two value.
Algorithm
Step 1: Start
Step 2: Declare three integer 'x', 'y' and 'a
Step 3: Define integer 'x' and 'y'
Step 4: Swapping the value of 'x' and 'y'
Step 5: Store O/P of step 4
Step 6: Print the swapped value
Step 7: Stop

Flow chart

Start

get x ,y, a

Swap the value of x and y

Print swapped value

End
//Write a C program to swap two value.
//write a program to swap two values//
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter two number : \n");
scanf("%d%d",&a,&b);
printf("\nBefore swapping\nfirst number : %d \nsecond number : %d",a,b);
c=a;
a=b;
b=c;
printf("\n\nAfter swapping\nfirst number : %d\nsecond number : %d",a,b);
getch();

Output result
Implement the single character input and string input
Algorithm
Step 1: Start
Step 2: Declare single character input 'a' and string character 'b'
Step 3: Define string character 'b'
Step 4: Take input 'b'
Step 5: Store O/P of step 4
Step 6: Print the string
Step 7: Define single character 'a'
Step 8: Read input 'a'
Step 9: Store O/P of step 4 of 'a'
Step 10:Print the single character
Step 11:Stop

Flow chart

Start

Get the string character and single character

put the character

print the input given

End
//Implement the single character input and string input
//implement the single character input and string input//
#include<stdio.h>
#include<conio.h>
int main()
{
char a,b[10];
printf("Enter any single character : ");
scanf("%c",&a);
printf("Enter your name : ");
scanf("%s",&b);
printf("You entered any single character:%c\nyour Name: %s",a,b);
getch();
return 0;
}
Output restult
Write a C program to find largest number among three conditional
operator.
Algorithm
Step 1: Start
Step 2: Declare four integer 'a', 'b', 'c' and 'x'
Step 3: Define the value of 'a', 'b' and 'c'
Step 4: Provide expression for larger number among 'a', 'b' and 'c'
Step 5: Store O/P of step 4 of 'x'
Step 6: Print 'x'
Step 7: Stop

Flow chart

Start

int a, b, c

a>b

b>c
a>c Print c is greater d Print c is greater

Print a is greater
Print b is greater

End
//Write a C program to find largest number among three
conditional operator.
//gretest among three using conditional operator//
#include<stdio.h>
#include<conio.h>
int main(){
int a,b,c,x;
printf("Enter the first number : ");
scanf("%d",&a);
printf("Enter the second number : ");
scanf("%d",&b);
printf("Enter the third number : ");
scanf("%d",&c);
x=(a>b>c)?a:(b>c)?b:c;
printf("The gretest number is %d ",x);
getch();
return 0;
}

Output restult

You might also like