0% found this document useful (0 votes)
3 views1 page

Microbits Programs

The document contains two C programs: the first program reverses a string using pointers, while the second program finds the largest number from a set of numbers provided as command line arguments. The first program prompts the user for a string and prints it in reverse, while the second program checks the command line inputs to determine the maximum value. Both programs demonstrate basic C programming concepts such as string manipulation and command line argument handling.

Uploaded by

suryasivadas2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Microbits Programs

The document contains two C programs: the first program reverses a string using pointers, while the second program finds the largest number from a set of numbers provided as command line arguments. The first program prompts the user for a string and prints it in reverse, while the second program checks the command line inputs to determine the maximum value. Both programs demonstrate basic C programming concepts such as string manipulation and command line argument handling.

Uploaded by

suryasivadas2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programs

Program 1: Reverse a String Using Pointer

#include <stdio.h>

int main()
{
char str[50];
char *p;

printf("Enter a string: ");


scanf("%s", str);

p = str;

while (*p != '\0')


p++;

printf("Reversed string: ");


while (p != str)
{
p--;
printf("%c", *p);
}

return 0;
}

Program 2: Largest Number Using Command Line Arguments

Program No 17: Largest among a set of numbers using command line argument

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])


{
int i, max;

if (argc < 2)
{
printf("Please enter numbers");
return 0;
}

max = atoi(argv[1]);

for (i = 2; i < argc; i++)


{
if (atoi(argv[i]) > max)
max = atoi(argv[i]);
}

printf("Largest number = %d", max);

return 0;
}

You might also like