Place Your Query
C Programming
- Control flow-based C Programs
- Enjoy Conditional Programming in C using If...else and switch statement.
- Good, Now write a C program to display "Hello World" on the screen.
- Write a C program to display Your Name, Address and City in different lines.
- C program to find sum of n numbers
- Write a C program For Addition of two numbers using Function.
- Write a Program to Find Simple Interest and Compound Interest.
- Write a Program to Convert Celsius To Fahrenheit and Vice Versa.
- Write a Program to Find Area and Perimeter of Circle, Triangle, Rectangle and Square.
- Write a Program to Swap Two Numbers Using Temporary Variables and Without Using Temporary Variables
- Write a C Program to Design a Simple Menu Driven Calculator
- Simple Expression Based C Programs
- 7. Components of C language
- 1. Introduction to C Programming Language
- 10. Operator Precedence and Associativity
- 11. Comments in C Programming
- 14. Fundamental Control Structure Statements in C [Part-1]
- 15. Fundamental Control Structure Statements in C [Part-2]
- 16. Looping Statements [Fundamental Control Structure Statements in C. #Part-3]
- 17. Keyword break, continue, return and exit [Fundamental Control Structure Statements in C. #Part-4]
- 2. Computer Languages
- 3. Interpreters vs Compilers vs Assemblers in programming languages
- 4. C Program Structure
- 5. Compile and Execute C Program
- 6. Errors in C Program
- 8. C Datatypes
- 9. Operators in C
- Control flow-based C Programs
- Demystifying Bit Masking: Unlocking the Power of Bitwise Operators in C-Language with best Examples.
- 18. Fundamentals of C Functions
- Show Remaining Articles (3)Collapse Articles
Java
AI ML
FAQs
- A Program to find Tokens in C code?
- What are the Common Coding Mistakes.
- Easy Learning, Python QAs for Beginner’s to Pro Part-1
- Easy Learning, Python QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-1
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner to Pro Part-3 (String Functions)
Python Interview Questions
- Easy Learning, Python QAs for Beginner’s to Pro Part-1
- Easy Learning, Python QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-1
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner to Pro Part-3 (String Functions)
Write a C program to display Your Name, Address and City in different lines.
In this article, I will show you how to write a C program to display your name, address and city in different lines using a simple printf statement or puts statement. This is a basic program that can help you learn the syntax and structure of C language.
To display something on the screen, we can use the printf function, which is part of the standard input/output library (stdio.h). The printf function takes a string as an argument and prints it to the standard output device, which is usually the console or the terminal.
To display multiple lines of text, we can use the escape sequence \n, which represents a newline character. This tells the printf function to move the cursor to the next line before printing the rest of the string.
Steps
- Include the stdio.h header file
- Define the main function
- Declare variables to store your name, address and city
- Assign values to the variables using string literals
- Use printf statements to display the variables in different lines
- Return 0 from the main function
Full Code [using printf() statement]
To display your name, address and city in different lines, you can write a C program like this:
#include<stdio.h> // include the stdio.h library
int main() // define the main function
{
// use printf to display your name, address and city in different lines
printf("John De Costa\n");
printf("Down Town Lane\n");
printf("Montiago\n");
return 0; // return 0 to indicate successful execution
}
Output
John De Costa
Down Town Lane
Montiago
Full Code [using puts() statement]
To display your name, address and city in different lines, you can write a C program like this:
#include<stdio.h> // include the stdio.h library
int main() // define the main function
{
// use printf to display your name, address and city in different lines
puts("John De Costa"); // with puts there is no need to use \n for new-lne.
puts("Down Town Lane"); // every puts statement starts from new line.
printf("Montiago");
return 0; // return 0 to indicate successful execution
}
Output
John De Costa
Down Town Lane
Montiago
Conclusion
Congratulations! You have successfully written a C program to display your name, address and city in different lines using a simple printf statement puts statement. I hope you enjoyed this blog post and learned something new. If you have any questions or feedback, please leave a comment below.
Thank you for reading!
EzyLearning!! Happy Learning!!