Command Line Programming For Greatest of Two numbers
Find Greatest of two number using command Line programming?
It is highly advisable to go through Command Line Arguments Post before even looking at the code. Please study this for TCS and come back to this post later.
#include <stdio.h> int main(int argc, char *argv[]) { int c[10]; int i,temp,j,greatest; j = 0; for(i=1; i<argc; i++) { temp = atoi(argv[i]); c[j] = temp; j++; } greatest = c[0]; for (i = 0; i < 10; i++) { if (c[i] > greatest) { greatest = c[i]; } } printf("Greatest of ten numbers is %d", greatest); return 0; }
Other TCS Coding Questions –
- TCS Coding Questions – 1
- TCS Coding Questions – 2
- Area of a Triangle
- TCS Command Line Arguments – Fibonacci Series
- TCS Command Line Program to Swap two numbers
- TCS String Reversal Using Command Line Programming
- Greatest of Two Numbers using CLP
- LCM of Two Number using CLP
- Average of Two Numbers
- Sum of Digits of a number
- Binary to Decimal
- Decimal to Binary
- Factorial of a Number
- Square Root of Prime Number
- Armstrong Number
Login/Signup to comment
Thanks a lot.
Command Line