0% found this document useful (0 votes)
2 views5 pages

About C Program

The document outlines a program focused on sequential flow in C programming, detailing objectives such as understanding program structure, input/output functions, and arithmetic operations. It includes a series of example programs demonstrating basic operations like addition, division, and area calculations, along with their respective outputs. The conclusion emphasizes the learning outcomes of executing these programs, enhancing logic-building skills and confidence in C programming.

Uploaded by

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

About C Program

The document outlines a program focused on sequential flow in C programming, detailing objectives such as understanding program structure, input/output functions, and arithmetic operations. It includes a series of example programs demonstrating basic operations like addition, division, and area calculations, along with their respective outputs. The conclusion emphasizes the learning outcomes of executing these programs, enhancing logic-building skills and confidence in C programming.

Uploaded by

prasiddhakadel1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Index: 21

Title of the Program: C | Sequential Flow Program

Objectives:
1. To understand the concept of sequential flow in C programming.
2. To study the structure of a C program.
3. To learn input and output functions (printf, scanf).
4. To perform arithmetic operations using C.
5. To implement mathematical formulas using sequential statements.
6. To develop logical thinking through simple programs.
7. To execute programs without using decision or looping statements.

Requirements:
 Computer System
 C Compiler (GCC / Turbo C / Dev C++)
 Text Editor or IDE

Theory:
Sequential flow is the simplest control flow in C programming. In this type of execution,
statements are executed one after another in the order written. Flow Representation:

Start → Input → Process → Output → End

Sequential flow programs include:

 Variable declaration
 Input operation
 Processing (calculations)
 Output operation

Procedure:
Computer Department-KMC, Bagbazar
1. WAP in C to print Hello KMC College
#include <stdio.h>
int main() {
printf("Hello KMC College");
return 0;
}

Output:

Hello KMC College

2. WAP in C to add two numbers


#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
return 0;
}

Output:

Enter two numbers: 5 3


Sum = 8

3. WAP in C to divide two numbers


#include <stdio.h>
int main() {
float a, b, div;
printf("Enter two numbers: ");
scanf("%f %f", &a, &b);
div = a / b;
printf("Division = %.2f", div);
return 0;
}

Output:

Enter two numbers: 15 3


Division = 5.00

Computer Department-KMC, Bagbazar


4. WAP in C to find the area of a circle
#include <stdio.h>
int main() {
float r, area;
printf("Enter radius: ");
scanf("%f", &r);
area = 3.14 * r * r;
printf("Area of circle = %.2f", area);
return 0;
}

Output:

Enter radius: 7
Area of circle = 153.86

5. WAP in C to find the area of a rectangle


#include <stdio.h>
int main() {
float l, b, area;
printf("Enter length and breadth: ");
scanf("%f %f", &l, &b);
area = l * b;
printf("Area of rectangle = %.2f", area);
return 0;
}

Output:

Enter length and breadth: 5 4


Area of rectangle = 20.00

6. WAP in C to calculate simple interest


#include <stdio.h>
int main() {
float p, r, t, si;
printf("Enter Principal, Rate and Time: ");
scanf("%f %f %f", &p, &r, &t);
si = (p * r * t) / 100;
printf("Simple Interest = %.2f", si);
return 0;
}

Computer Department-KMC, Bagbazar


Output:

Enter Principal, Rate and Time: 1000 5 2


Simple Interest = 100.00

7. WAP in C to convert Celsius to Fahrenheit


#include <stdio.h>
int main() {
float c, f;
printf("Enter temperature in Celsius: ");
scanf("%f", &c);
f = (c * 9/5) + 32;
printf("Temperature in Fahrenheit = %.2f", f);
return 0;
}

Output:

Enter temperature in Celsius: 25


Temperature in Fahrenheit = 77.00

8. WAP in C to swap two numbers (using third variable)


#include <stdio.h>
int main() {
int a, b, temp;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
temp = a;
a = b;
b = temp;
printf("After swapping: a = %d, b = %d", a, b);
return 0;
}

Output:

Enter two numbers: 8 12


After swapping: a = 12, b = 8

9. WAP in C to calculate the average of three numbers


#include <stdio.h>
int main() {
float a, b, c, avg;
printf("Enter three numbers: ");

Computer Department-KMC, Bagbazar


scanf("%f %f %f", &a, &b, &c);
avg = (a + b + c) / 3;
printf("Average = %.2f", avg);
return 0;
}

Output:

Enter three numbers: 5 10 15


Average = 10.00

10. WAP in C to find the perimeter of a rectangle


#include <stdio.h>
int main() {
float l, b, perimeter;
printf("Enter length and breadth: ");
scanf("%f %f", &l, &b);
perimeter = 2 * (l + b);
printf("Perimeter of rectangle = %.2f", perimeter);
return 0;
}

Output:

Enter length and breadth: 5 4


Perimeter of rectangle = 18.00

Conclusion:
By performing the above sequential flow programs in C at KMC College, we understood how
statements are executed line by line. By writing and running these WAP programs, we learned
how to take input, perform calculations, and display output using sequential execution. By
practicing basic, intermediate, and mixed programs, we strengthened our logic-building skills
and confidence in C programming.

Computer Department-KMC, Bagbazar

You might also like