C Exercises: Print your name, date of birth, and mobile number
C Basic Declarations and Expressions: Exercise-1 with Solution
Print name, DOB, and mobile number
Write a C program to print your name, date of birth, and mobile number.
Pictorial Presentation:
C Code:
#include <stdio.h>
int main()
{
// Print Name
printf("Name : Alexandra Abramov\n");
// Print Date of Birth
printf("DOB : July 14, 1975\n");
// Print Mobile Number
printf("Mobile : 99-9999999999\n");
// Indicate successful execution
return(0);
}
Explanation:
In the exercise above -
- #include <stdio.h>: This line includes the standard input-output library, which contains functions for reading and writing data to and from the console.
- int main(): This is the main function of the program, where execution begins. It returns an integer value, typically 0, to indicate successful execution.
- Inside the "main()" function, there are three printf statements. The "printf()" function is used to print formatted text to the console. Each printf statement prints a line of text with specific information:
- printf("Name : Alexandra Abramov\n"); prints "Name : Alexandra Abramov" followed by a newline character, which moves the cursor to the next line.
- printf("DOB : July 14, 1975\n"); prints "DOB : July 14, 1975" followed by a newline character.
- printf("Mobile : 99-9999999999\n"); prints "Mobile : 99-9999999999" followed by a newline character.
- return(0);: This line indicates the end of the main function and returns 0.
Sample Output:
Name : Alexandra Abramov DOB : July 14, 1975 Mobile : 99-9999999999
Flowchart:
C Programming Code Editor:
Previous: C Basic Declarations and Expressions Exercises Home
Next: Write a C program to print a block F using hash (#), where the F has a height of six characters and width of five and four characters.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/c-programming-exercises/basic-declarations-and-expressions/c-programming-basic-exercises-1.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics