Just for Fun: A Rosary in C

The following little C program is a fun way to imagine a computer praying a prayer.

For this demonstration, we chose the rosary, a form of devotion where a set of prayers said in order, accompanying prayer beads. Many religions use repetitive prayer and prayer beads as a means of focusing the heart and mind and spirit on God. Repetitive prayers, even simple ones, can be especially useful for people whose minds tend to obsess or become caught in negative thoughts.

For the purposes of the demonstration program, the standard rosary is used. One need not be a Catholic to enjoy the use of prayer beads, and it is possible to substitute other prayers to suit your taste. Many religions use such repetition with beads as a means of focusing the heart, mind and spirit on God.

The rosary is usually prayed as follows: After making the sign of the cross, say an Apostle's Creed and an Our Father. Three Hail Marys, a Glory Be. Then, for each of five sets of beads, Announce the corresponding Mystery, followed by another Our Father. Say ten Hail Marys and end with a Glory Be. After all five sets are completed, end with a Hail Holy Queen.

Our little C program isn't thinking or experiencing prayer. It's offered here, just for fun, as an example of the programming language, and to provide another interesting way to consider the contemplative practice of the rosary. It's fun to imagine a computer praying a prayer, and the rosary is useful because it's a relatively easy sequence.

A Program that Prays the Rosary

int main() {

char* myst_array [5] = {"The first luminous mystery is the baptism in Jordan", "The second luminous mystery is the wedding at Cana", "The third luminous mystery is proclamation of kingdom ", "The fourth luminous mystery is the transfiguration", "The fifth luminous mystery is the Eucharist"};
char* hailmary = "Hail Mary full of Grace, the Lord is with thee, blessed art thou among women and blessed is the fruit of thy womb, Jesus. Holy Mary mother of God, pray for us sinners now and at the hour of our death. Amen";
char* glorybe = "Glory be to the father and to the Son and to the Holy spirit. As it was in the beginning, is now, and ever shall be. World without end. Amen";
char* signofcross = "In the name of the Father, and of the Son, and of the Holy Spirit. Amen.";
char* apostlescreed = "I believe in God, the Father almighty, Creator of Heaven and earth. And in Jesus Christ, His only Son, our Lord, Who was conceived by the Holy Spirit, born of the Virgin Mary, suffered under Pontius Pilate; was crucified, died, and was buried. He descended into Hell. The third day He rose again from the dead. He ascended into Heaven, and sits at the right hand of God, the Father almighty. He shall come again to judge the living and the dead. I believe in the Holy Spirit, the holy Catholic Church, the communion of saints, the forgiveness of sins, the resurrection of the body, and life everlasting. Amen.";
char* ourfather = "Our Father, who art in Heaven, hallowed be Thy Name. Thy kingdom come, Thy will be done on earth as it is in Heaven. Give us this day our daily bread, and forgive us our trespasses, as we forgive those who trespass against us. And lead us not into temptation, but deliver us from evil. Amen.";
char* omyJesus = "O My Jesus, forgive us our sins, save us from the fires of Hell; lead all souls into Heaven, especially those in most need of Thymercy. Amen.";  /*also known as Fatima prayer, optional */
char* hailholyqueen = "Hail, holy queen, mother of mercy; our life, our sweetness, and our hope. To thee do we cry, poor banished children of Eve. To thee do we send up our sighs, mourning and weeping in this vale of tears. Turn, then, most gracious advocate, thine eyes of mercy toward us. And after this, our exile, show unto us the blessed fruit of thy womb, Jesus. O clement, O loving, O sweet Virgin Mary. Pray for us, O holy Mother of God, that we may be made worthy of the promises of Christ. Amen.";
int n;
int i;

printf("%s\n  %s\n  %s \n", signofcross, apostlescreed, ourfather);          /* the starting three prayers*/
for (n=0; n<3; n++)
    printf("%s\n", hailmary);
    }                                                                        /* 3 Hail Mary's for faith, hope, charity */ 
printf("%s\n", glorybe);                                                     /* a Glory Be */
for (i=0; i < 5; i++) {
puts(myst_array[i]);                                                         /* one of the mysteries */
printf ("%s\n",  ourfather);                                                 /*   say an our father*/
    for (n=0; n < 10; n++)   {
        printf("%s\n", hailmary);                                            /* the 10 Hail Mary prayers */
    printf("%s\n", glorybe);                                                 /* another Glory Be */
printf ("%s\n", hailholyqueen);                                              /*the entire prayer ends with a Hail Holy Queen */

The Program in Action

the output

We're always looking for fellow Ministrants!

Got what it takes to take the Ministrants Oath? Great!

Learn about the Oath

This website uses cookies for general analytics. Except when you share it with us through our contact form, we do not harvest, ask for, or gather any personal data. By continuing on this site you acknowledge our terms and conditions .