Exercise 1.10. Write, compile and run a program that displays your Name, Surname, Date of Birth, Place of Birth, Phone Numbers, Websites, Job Title, and Marital Status.

Source Code

Brief explanation is provided after the source code.

#include <stdio.h>

int main(int argc, char ** argv) {
    printf("Surname: Fokwa .T\n");
    printf("Given Name: Divine\n");
    printf("Date of Birth: NULL\n");
    printf("Place of Birth: NULL\n");
    printf("Phone Numbers: NULL\n");
    printf("Websites: divostar.com, divosays.com\n");
    printf("Job Title: Business Analyst\n");
    printf("Marital Status: Single\n");
    return 0;

When you compile and execute the above program it produces the following result on Linux:

Surname: Fokwa .T
Given Name: Divine
Date of Birth: NULL
Place of Birth: NULL
Phone Numbers: NULL
Websites: divostar.com, divosays.com
Job Title: Business Analyst
Marital Status: Single

Brief Explanation

  • This program makes use of the printf function to display the necessary information. printf is a library function that prints output, in this case the string of characters between the quotes.
  • \n is an escape sequence for newline. This makes the output to be displayed on separate lines.
  • A return value of zero implies normal termination; non-zero values signal unusual or erroneous termination conditions.
  • The first line of the program, #include tells the compiler to include information about the standard input/output library.
  • The main function takes two arguments. The first (conventionally called argc, for argument count) is the number of command-line arguments the program was invoked with; the second (argv, for argument vector) is a pointer to an array of character strings that contain the arguments, one per string. We customarily use multiple levels of pointers to manipulate these character strings.
  • Since we are not passing any command-line arguments in this program, the main function could be written without those arguments. (int main(){})

Add comment

Security code