[go: up one dir, main page]

0% found this document useful (0 votes)
7 views8 pages

C Program

The document outlines a series of C programming exercises focused on input/output statements, operators, and expressions. It includes example programs for printing messages, performing arithmetic operations, and converting temperatures, along with flowcharts and expected outputs. The result confirms successful implementation and verification of the programs.

Uploaded by

rockydeva8
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)
7 views8 pages

C Program

The document outlines a series of C programming exercises focused on input/output statements, operators, and expressions. It includes example programs for printing messages, performing arithmetic operations, and converting temperatures, along with flowcharts and expected outputs. The result confirms successful implementation and verification of the programs.

Uploaded by

rockydeva8
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
You are on page 1/ 8

EX.

No:1 INPUT AND OUTPUT STATEMENTS, OPERATORS AND EXPRESSIONS


13.08.2025
AIM:
To create C program that utilizes the input/output library to read data from the keyboard and to display
data on the computer.

1.Write a program that prints "Hello, World!"

Program:

#include<stdio.h>

int main()

printf("Hello, World!");

return 0;

Flowchart:
Start

Hello, World!

Stop

Output:

Hello, World!

2.Write a program that asks the user to enter their name and prints "Hello, <name>"

Program:

#include<stdio.h>

int main()

char a[100];
printf("Enter your name : ");

scanf("%s",a);

printf("Hello, %s",a);

return 0;

Flowchart:
Start

Declare a[100]

Enter your name :

Read a

Hello,<name>

Stop

Input:

Enter your name : Ashvitha

Output:

Hello, Ashvitha

3. Write a program that takes two integer from user and prints the sum of it.

Program:

#include<stdio.h>

int main()

{
int a,b;

printf("Enter two numbers: ");

scanf("%d %d",&a,&b);

printf("The sum is : %d",a+b);

return 0;

Flowchart:
start

Declare a,b

Enter two
numbers:

Read a,b

a+b

The sum is :
a+b

stop

Input:

Enter two number: 2 3

Output:

The sum is : 5

4.Write a program which prints out :6.23e+00.

Program:

#include<stdio.h>
int main()

float n=6.23;

printf("%.2e",n);

return 0;

Flowchart:
Start

n=6.23

Print n in
scientific form

Stop

Output:

6.23e+00

5.Calculate the area of rectangle.

Program:

#include<stdio.h>

int main()

int length,height;

printf("Enter the length and height: ");

scanf("%d %d",&length,&height);

printf("Area of the rectangle: %d",length*height);

return 0;

}
Flowchart:

Start

Declare length, height

Enter length and


height:

Read length, height

length* height

Area of rectangle:
length*height

stop

Input:

Enter the length and height: 3 4

Output:

Area of the rectangle: 12

6.Convert Celsius to Fahrenheit

Program:

#include<stdio.h>

int main()

float C;
printf("Enter the temperature in Celsius:");

scanf("%f",&C);

float f= (C *(9/5) + 32);

printf("Fahrenheit is %.2f degree ",f);

return 0;

Input:

Enter the temperature in celsius:100

Output:

Fahrenheit is 212.00

7.Swap two numbers.

Program:

#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter two numbers ");
scanf("%d %d",&a,&b);
printf("Before swap a=%d and b=%d",a,b);
c=a;
a=b;
b=c;
printf("\nAfter swap a=%d and b=%d",a,b);
return 0;
}
Output

Enter two numbers 6 4


Before swap a=6 and b=4
After swap a=4 and b=6
8.Write single c statements to print the message “This is a c program” with each word on a single
separate line.

#include<stdio.h>

int main()

printf("This\nis\na\nC\nProgram");

return 0;

Output:

This

is

Program

9.Remainder of two numbers

Program:

#include<stdio.h>

int main()

int a, b;

printf("Enter two numbers: ");

scanf("%d %d",&a,&b);

int c=a%b;

printf("The remainder of %d and %d is %d",a,b,c);


return 0;

Input:

Enter two numbers: 4 3

Output:
The remainder of 4 and 3 is 1
10. Find the square of a number.

Program:

#include <stdio.h>

int main()

int a;

printf("Enter a number: ");

scanf("%d",&a);

printf("Square of the number is %d",a*a);

return 0;

Input:

Enter a number: 3

Output:

Square of the number is 9

RESULT:

Thus C program were successfully implemented and verified that it utilizes the input/output, operations
and expression to read data from keyboard and to display data on the computer screen.

You might also like