Documente Academic
Documente Profesional
Documente Cultură
Leap Year
Given a number N, the task is to check if N is a Leap Year or not using Command Line Arguments.
#include <stdio.h>
// Function to check
1
&& (year % 100 != 0))
|| (year % 400 == 0))
return 1;
else
return 0;
}
// Driver code
int main(int argc, char* argv[])
{
int n;
else {
return 0;
}
================================================================
class GFG {
2
// Function to check
// if year is a leap year or not
public static int isLeapYear(int year)
{
// Driver code
public static void main(String[] args)
{
3
System.out.println("No command line +
"arguments found.");
}
}
===============================================
// C program to find
// the Prime Numbers from 1 to N
// using command line arguments
#include <stdio.h>
4
// Function to check if x is prime
int isPrime(int x)
{
int i;
// x is prime
return 1;
}
// Driver code
int main(int argc, char* argv[])
{
int n;
5
// Convert it from string type to
integer type
// using function "atoi( argument)"
n = atoi(argv[1]);
// Check if n is prime
if (isPrime(n) == 1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
class GFG {
// x is prime
return 1;
6
}
// Driver code
public static void main(String[] args)
{
// Check if n is prime
if (isPrime(n) == 1)
System.out.println("Yes");
else
System.out.println("No");
}
else
System.out.println("No command line
"
+ "arguments
found.");
}
}
7
// C program to find
// the Prime Numbers from 1 to N
// using command line arguments
#include <stdio.h>
// x is prime
return 1;
}
// Check if i is prime
// If yes then print it
// else continue to next number
if (isPrime(i) == 1)
printf("%d, ", i);
}
printf("\n");
}
// Driver code
int main(int argc, char* argv[])
{
int n;
9
}
class GFG {
// x is prime
return 1;
}
// Loop from 2 to n
// to find all prime numbers in between
for (i = 2; i <= n; i++) {
// Check if i is prime
10
// If yes then print it
// else continue to next number
if (isPrime(i) == 1)
System.out.print(i + ", ");
}
System.out.println();
}
// Driver code
public static void main(String[] args)
{
#include <stdio.h>
#include <stdlib.h> /* atoi */
// Driver code
int main(int argc, char* argv[])
{
else {
13
num1 = atoi(argv[1]);
num2 = atoi(argv[2]);
class GFG {
// Driver code
public static void main(String[] args)
{
14
// Get the command line argument
and
// Convert it from string type to
integer type
int num1 =
Integer.parseInt(args[0]);
int num2 =
Integer.parseInt(args[1]);
15
// C program to compute the HCF of two numbers
// using command line arguments
#include <stdio.h>
#include <stdlib.h> /* atoi */
// Driver code
int main(int argc, char* argv[])
{
16
// Check if the length of args array is 1
if (argc == 1)
printf("No command line arguments
found.\n");
else {
class GFG {
// Driver code
public static void main(String[] args)
17
{
18
// C program to swap the two numbers
// using command line arguments
#include <stdio.h>
#include <stdlib.h> /* atoi */
// y becomes x
y = x - y;
// x becomes y
x = x - y;
// Driver code
int main(int argc, char* argv[])
{
else {
20
}
// Java program to swap the two numbers
// using command line arguments
class GFG {
// y becomes x
y = x - y;
// x becomes y
x = x - y;
// Driver code
public static void main(String[] args)
{
21
// Swap the numbers
swap(num1, num2);
}
Else
#include <stdio.h>
#include <stdlib.h> /* atoi */
22
// Function to compute the average of two
numbers
int average(int a, int b)
{
return (a + b) / 2;
}
// Driver code
int main(int argc, char* argv[])
{
else {
class GFG {
23
// Function to compute the average of two
numbers
static int average(int a, int b)
{
return (a + b) / 2;
}
// Driver code
public static void main(String[] args)
{
#include <stdio.h>
25
#include <stdlib.h> /* atoi */
return C;
}
// Driver code
int main(int argc, char* argv[])
{
else {
26
printf("%d\n", greatest(num1, num2,
num3));
}
return 0;
}
class GFG {
return C;
}
// Driver code
public static void main(String[] args)
{
27
TCS Coding Practice Question | Check Odd
or Even
Given a number, the task is to check if this number is Odd or Even using Command Line Arguments.
A number is called even if the number is divisible by 2 and is called odd if it is not divisible by 2.
28
C PROGRAM:-
Java Program:-
29
TCS Coding Practice Question |
Palindrome String
Given a string, the task is to check if this String is Palindrome or not using Command Line Arguments.
30
31
TCS Coding Practice Question | Sum of
Digits of a number
32
Given a number, the task is to find the Sum of Digits of this number using Command Line Arguments
C PROGRAM:-
33
34
35
TCS Coding Practice Question | Check
Palindrome Number
Given a number, the task is to check if this number is Palindrome or not using Command Line
Arguments.
36
37
38
TCS Coding Practice Question | Reverse a
String
Given a string, the task is to reverse this String using Command Line Arguments.
39
40
41
42
TCS Coding Practice Question | Fibonacci
Series
Given a number ‘n’, the task is to print the the Fibonacci series using Command Line Arguments. The
Fibonacci numbers are the numbers in the following integer sequence.
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation
43
with seed values
Example:-
Approach:
44
45
TCS Coding Practice Question | Factorial
of a Number
Given a number, the task is to find the Factorial of this number using Command Line Arguments.
Factorial of a non-negative integer is the multiplication of all integers smaller than or equal to n
46
Example:-
47
48
TCS Coding Practice Question | Reverse a
Number
49
Given a number, the task is to reverse this number using Command Line Arguments.
50
51
Check whether the given character is in
upper case, lower case or non alphabetic
character
52
Given a character, the task is to check whether the given character is in upper case, lower case or
non-alphabetic character
53
Check input character is alphabet, digit or
special character
54
55