0% found this document useful (0 votes)
2 views

C Programs Week1

The document contains four C programming exercises focused on printing formatted output and performing addition of integers. Each program includes an algorithm, pseudo code, and the actual C code implementation. The exercises range from printing a formatted message to reading user input for addition.

Uploaded by

boddanaomkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

C Programs Week1

The document contains four C programming exercises focused on printing formatted output and performing addition of integers. Each program includes an algorithm, pseudo code, and the actual C code implementation. The exercises range from printing a formatted message to reading user input for addition.

Uploaded by

boddanaomkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

C PROGRAMS

WEEK-1
PROGRAM-1
1. Write a C program that prints the following formatted output.
**************
Hello WORLD
Name: Ganesh
Department: AIML
**************

Algorithm
1. Start
2. Print a line of asterisks (**************).
3. Print the message "Hello WORLD".
4. Print the name as "Name: Ganesh" using a tab space.
5. Print the department as "Department: AIML" using a tab
space.
6. Print another line of asterisks (**************).
7. End

Pseudo Code
START
PRINT "**************"
PRINT "Hello WORLD"
PRINT "Name: Ganesh" // Display name with tab space
PRINT "Department: AIML" // Display department with tab space
PRINT "**************"
END

Program
#include<stdio.h>
int main()
{
printf("**************\n");
printf("Hello WORLD\n");
printf("Name:\t Ganesh\n");
printf("Department:\t AIML\n");
printf("**************\n");
return 0;
}
PROGRAM-2
2. Write a C Program that declares three integer variables
number1, number2 and sum to perform addition of two numbers
and display their sum.

Algorithm
1. Start
2. Declare three integer variables: number1, number2, and sum.
3. Initialize number1 to 10.
4. Initialize number2 to 6.
5. Calculate the sum by adding number1 and number2:
sum = number1 + number2
6. Print the value of sum.
7. End

Pseudo Code

START
Declare integer number1, number2, sum
number1 = 10 // Assign value 10 to number1
number2 = 6 // Assign value 6 to number2
sum = number1 + number2 // Calculate the sum
PRINT "The Sum is " + sum // Display the sum
END

Program

#include<stdio.h>
int main()
{
int number1, number2,sum;
number1=10;
number2=6;
sum=number1+number2;
printf("The Sum is %d ", sum);
return 0;
}
PROGRAM-3
3. Write a C Program that declares two integer variables number1
and number2 to perform addition of two numbers and display
their sum.

Algorithm
1. Start
2. Declare two integer variables: number1 and number2, and
assign them the values 10 and 6, respectively.
3. Calculate the sum directly in the printf statement by adding
number1 and number2.
4. Print the sum.
5. End

Pseudo Code

START
Declare integer number1 = 10, number2 = 6
PRINT "The Sum is " + (number1 + number2) // Directly print
the sum
END

Program

#include<stdio.h>
int main()
{
int number1=10, number2=6;
printf("The Sum is %d ", number1+number2);
return 0;
}
PROGRAM-4
4. Write a C Program to read two numbers add them and display
their sum.

Algorithm
1. Start
2. Declare two integer variables: number1 and number2.
3. Prompt the user to enter two integers.
4. Read the two integers from the user.
5. Calculate the sum by directly adding number1 and number2 in
the print statement.
6. Print the sum.
7. End

Pseudo Code

START
Declare integer number1, number2
PRINT "Enter two integers: "
READ number1, number2
PRINT "The Sum is " + (number1 + number2) // Directly display
the sum
END

Program

#include<stdio.h>
int main() {
int number1, number2;
printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);
printf("The Sum is %d ", number1+number2);
return 0;
}

You might also like