Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1: Write a C program called take as command line input a variable number of str

ID: 3930866 • Letter: Q

Question

Q1: Write a C program called take as command line input a variable number of strings and store in a linked list the uppercase equivalent of each string. Each new string should be inserted at the HEAD of the linked list. Each node of the linked list should contain 2 variables: i) a character array to hold a string, ii) a pointer to the next node in the linked list. It should also contain a function void print_linked_list(struct *node) to iterate over the linked list and print the strings stored in each node of the linked list.

Explanation / Answer

#include<stdio.h>

#include<conio.h>

int string_ln(char*);

void main() {

   char str[20];

   int length;

   clrscr();

  

   printf(" Enter any string : ");

   gets(str);

  

   length = string_ln(str);

   printf("The length of the given string %s is : %d", str, length);

   getch();

}

int string_ln(char*p) /* p=&str[0] */

{

   int count = 0;

   while (*p != '') {

      count++;

      p++;

   }

   return count;

}