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

Hey could someone help me with this simple C program?! its an intro class so ple

ID: 3692334 • Letter: H

Question

Hey could someone help me with this simple C program?! its an intro class so please keep it as simple as possible! Thank you!!!

Write a program, called dline.c, that prints out different greetings based on the command line arguments . ./cmdline last_name Hello, Mr. last_name . ./cmdline last_name first_name My name is first_name last_name ./cmd line Hi, Mr. last_name, your score is test_score last-name test-score · Some sample output: Hello, Mr. Jones My name is Joe Smith Hi, Mr. Doe, your score is 87.5

Explanation / Answer

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
int number_only(const char *);
int main(int argc,char *argv[])
{
   int n;
   clrscr();
   n=number_only(argv[2]);
   if(argc==2)
   {
       printf("Hello, Mr.%s",argv[1]);
   }
   if(argc==3)
   {

       if(n==1)
           printf("Hi,Mr.%s, your score is %s ",argv[1],argv[2]);
       else
           printf("My name is %s %s",argv[1],argv[2]);
   }

   return 0;
}
int number_only(const char *s)
{
   while(*s)
   {
       if(isdigit(*s++)==0)
           return 0;
   }
   return 1;
}