Breaking News



Glad New Yr 2022

Most sensible 20 Coding Program Ask In Examination & Interview –

There is just one query for 20 mins.

  1. It has 10 makes an attempt(We will be able to assemble simplest 10 instances).
  2. We should get started our code from the scratch.
  3. The coding platform is split into two, one for writing the code and different for output. We will have to write the entire program.
  4. We will be able to’t use any enter purposes like scanf(), getch(), getchar().
  5. The enter to be supplied will have to be learn as command line arguments.

We should simplest print actual output in Command Line Arguments Questions for TCS
Process –

  1. Output should now not be re-framed by way of additional phrases.
  2. If there may be any error, the mistake will probably be proven within the output conversation field.
  3. The mistakes are obviously discussed.
  4. If there aren’t any mistakes, a message like “compiled effectively” will probably be published.
  5. In conjunction with that they’re going to point out 4 check instances are ‘handed’ or possibly ‘failed’.
  6. They’re indicated like personal and public check instances. They have got now not discussed what’s the check case, which is obscure in TCS Command Line Arguments Techniques.

Dont Bring together over and over since compiler takes 25 seconds and every time you assemble 25 seconds will change into lesser within the time you need to code.

1 Command Line Program for Unusual Even

#come with <stdio.h>
int primary(int argc, char *argv[])
{
int quantity;
quantity = atol(argv[1]);
if(quantity % 2 == 0)
printf(“%d is even.”, quantity);
else
printf(“%d is abnormal.”, quantity);
go back 0;
}

2 Command Line Program to Convert Binary to Octal

This can be a extremely smart program very quick and fast means –
#come with<stdio.h>
void primary(int argc,char *argv[])
{

lengthy int n,r,c,b=1,s=0;
n=atoi(argv[1]);
c=n;
whilst(c!=0)
{
r=cpercent10;
s=s+r*b;
c=c/10;
b=b*2;
}
printf(“%lo”,s);
getch();
}

3 Command Line Program to Convert Decimal to Octal

That is extremely smart quick and fast program –

#come with<stdio.h>
int primary(int argc,char *argv[])
{
int n,s=0,b=1,r;
n=atoi(argv[1]);
int c=n;
whilst(c>0)
{

r=cpercent8;
s=s+r*b;
c=c/8;
b=b*10;
}
printf(“%d”,s);
getch();
}

4 Command Line Program to test if a yr is Bounce Yr or Now not

#come with<stdio.h>
void primary(int argc,char *argv[])
{
int n;
n=atoi(argv[1]);
if(npercent4==0)
{
if(npercent100==0)
{
if(npercent400==0)
printf(“Bounce Yr”);
else
printf(“Now not Bounce Yr”);
}
else

printf(“Bounce Yr”);
}
else
printf(“Now not Bounce Yr”);
getch();
}

5 Command Line Program to search out House of Circle

Write a C program to search out the world of a circle with radius supplied. The worth of radius certain integer handed to this system as the primary command line parameter. Write the output to stdout formatted as a floating level quantity rounded to EXACTLY 2 decimal precision WITHOUT another further textual content.

Medical layout(akin to 1.00E+5) will have to NOT be used whilst printing the output. Chances are you’ll think that the inputs will probably be such that the output is not going to exceed the most important conceivable actual quantity that may be saved in a drift kind variable.

#come with<stdio.h>
#come with<stdlib.h>
int primary(int argc, char * argv[])
{
if(argc==1)
{

printf(“No arguments”);
go back 0;
}
else
{
int radius;
drift pi=3.14;
drift house;
radius=atoi(argv[1]);
house=pi*radius*radius;
printf(“%.2f”,house);
go back 0;
}
}
Write a C program to search out the world of a circle with radius supplied. The worth of radius certain integer handed to this system as the primary command line parameter. ​ Write the output to stdout formatted as a floating level quantity rounded to EXACTLY 2 decimal precision WITHOUT another further textual content.

Medical layout(akin to 1.00E+5) will have to NOT be used whilst printing the output.

6 Command Line Program to search out House of Traingle

#come with <stdio.h>
int primary(int argc, char *argv[])
{

int base, peak;
drift house;
base = atol(argv[1]);
peak = atol(argv[2]);
house = base*peak/2;
printf(“%f”,house);
}

7 Command Line Program to Take a look at if a Quantity is Palindrome or Now not

Palindrome Quantity Command Line Programming

#come with <stdio.h>
int primary(int argc, char *argv[])
{
int num, reverse_num=0,the rest,temp;
num = atol(argv[1]);
temp=num;
whilst(temp!=0)
{
the rest=temppercent10;
reverse_num=reverse_num*10+the rest;
temp/=10;
}
if(reverse_num==num)
printf(“%d is a palindrome quantity”,num);
else
printf(“%d isn’t a palindrome quantity”,num);
go back 0;

}

8 Command Line Program to Take a look at if a String is Palindrome or Now not

#come with <stdio.h>
#come with <string.h>
void isPalindrome(char str[])
{
int l = 0;
int h = strlen(str) – 1;
whilst (h > l)
{
if (str[l++] != str[h–])
{
printf(“%s is Now not Palindromen”, str);
go back;
}
}
printf(“%s is palindromen”, str);
}
int primary(int argc, char *argv[])
{
int i,ok;
int strsize = 0;
for (i=1; i<argc; i++) {
strsize += strlen(argv[i]);
if (argc > i+1)
strsize++;
}
char *cmdstring;
cmdstring = malloc(strsize);
cmdstring[0] = ‘’;
for (ok=1; ok<argc; ok++) {
strcat(cmdstring, argv[k]);
if (argc > ok+1)
strcat(cmdstring, ” “);
}
isPalindrome(cmdstring);
}

9 Command Line Program to Take a look at if a Quantity is Top or Now not

#come with <stdio.h>
int primary(int argc, char *argv[])
{
int n, i, flag = 0;
n = atol(argv[1]);
for(i=2; i<=n/2; ++i)
{
if(npercenti==0)
{
flag=1;
destroy;
}
}
if (flag==0)
printf(“%d is a major quantity.”,n);
else
printf(“%d isn’t a major quantity.”,n);
go back 0;
}

10 Command Line Program to Opposite a Quantity

#come with<stdio.h>
#come with<stdlib.h>
int primary(int argc, char *argv[])
{
if(argc==1)
{
printf(“No Arguments”);
go back 0;
}
else
{
int n,reverseNumber,temp,rem;
n=atoi(argv[1]);
temp=n;
reverseNumber=0;
whilst(temp)
{
rem=temppercent10;
reverseNumber=reverseNumber*10+rem;
temp=temp/10;
}
printf(“%d”,reverseNumber);
go back 0;
}
}

Most sensible 20 Coding Program Ask In Examination & Interview

11 Calculate Sq. Root with out the usage of Math.h sqrt Serve as

#come with<stdio.h>
#come with<stdlib.h>
int primary(int argc, char *argv[])
{
if(argc==1)
{
printf(“No arguments”);
go back 0;
}
else
{
int n;
n=atoi(argv[1]);
drift i=0.00;
whilst(i*i<=n)
{
i=i+0.001;
}
i=i-0.001;
printf(“%.2f”,i);
}
}

12 Sq. Root of Top Quantity the usage of Command Line Argument

#come with<stdio.h>
#come with<stdlib.h>
#come with<stdbool.h>
#come with<math.h>
bool isPrime(int n)
{
if(n<2)
go back false;
int i;
for(i=2;i*i<=n;i++)
{
if(npercenti==0)
go back false;
}
go back true;
}
int primary(int argc, char *argv[])
{
if(argc==1)
{
printf(“No arguments”);
go back 0;
}
else
{
int n;
n=atoi(argv[1]);
drift sq=0;
if(isPrime(n))
{
sq=sqrt(n);
printf(“%.2f”,sq);
}
else
printf(“%.2f”,sq);
go back 0;
}
}

13 Nth Fibonacci Quantity

#come with<stdio.h>
#come with<stdlib.h>
int fib(int n)
{
int a=0,b=1,c,i;
if(n==0) go back a;
for(i=2;i<=n;i++)
{
c=a+b;
a=b;
b=c;
}
go back b;
}
int primary(int argc, char * argv[])
{
if(argc==1)
{
printf(“No arguments”);
go back 0;
}
else
{
int n;
n=atoi(argv[1]);
printf(“%d”,fib(n));
go back 0;
}
}

14 Decimal to Binary

#come with<stdio.h>
#come with<stdlib.h>
int primary(int argc, char *argv[])
{
if(argc==1)
{
printf(“No Arguments “);
go back 0;
}
else
{
int n;
n=atoi(argv[1]);
int binaryN[64];
int i=0;int j;
whilst(n>0)
{
//storing in binary array rest of quantity
binaryN[i]=npercent2;
n=n/2;
i++;
}
//printing opposite array
whilst(i)
{
printf(“%d”,binaryN[–i]);
}
go back 0;
}
}

Most sensible 20 Coding Program Ask In Examination & Interview

15 Binary to decimal the usage of Command Line Language

#come with <stdio.h>
int primary(int argc, char *argv[])
{
int num,binary,decimal=0,rem,base=1;
num=atoi(argv[1]);
binary=num;
whilst(num>0)
{
rem=numpercent2;
decimal =rem*base;
num=num/10;
base=base*2;
}
printf(“%d”,decimal);
go back 0;
}

16 Sum of all of the digits of a host the usage of Command Line Language

#come with <stdio.h>
#come with <stdlib.h>
int primary(int argc, char * argv[])
{
lengthy num, temp, digit, sum = 0;
if(argc == 1 || argc > 2)
{
printf(“Input the numbern”);
go out(1);
}
num = atoi (argv[1]) ;
temp = num;
whilst (num > 0)
{
digit = num % 10;
sum = sum + digit;
num /= 10;
}
printf(“Sum of the digits of %ld = %ldn”, temp, sum);
}

17 Moderate of Two Numbers the usage of Command Line Language

#come with <stdio.h>
int primary(int argc, char * argv[])
{
int sum = 0,i = 1,depend = 0;
if(argc == 1)
{
printf(“Input the quantity n”);
go out(1);
}
depend = argc – 1;
whilst (i <= depend )
{
sum += atoi (argv[i]) ;
i++;
}
printf(“Avg of the numbers.%dn”, sum/depend);
}

18 LCM of Two Numbers the usage of Command Line Language

#come with <stdio.h>
#come with <stdlib.h>
int primary(int argc, char * argv[])
{
int n1,n2,x,y;
if (argc == 1 || argc > 3)
{
printf(“Input Two Numberrn”);
go out(0);
}
x=atoi(argv[1]);
y=atoi(argv[2]);
n1 = x; n2 = y;
whilst(n1!=n2){
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
printf(“L.C.M of %d & %d = %d rn”,x,y,x*y/n1);
go back 0;
}

19 Command Line Programming For Biggest of Two numbers

#come with <stdio.h>
int primary(int argc, char *argv[])
{
int c[10];
int i,temp,j,largest;
j = 0;
for(i=1; i<argc; i++)
{
temp = atoi(argv[i]);
c[j] = temp;
j++;
}
largest = c[0];
for (i = 0; i < 10; i++) {
if (c[i] > largest) {
largest = c[i];
}
}
printf(“Biggest of ten numbers is %d”, largest);
go back 0;
}

20 Command Line Program for Swapping two Numbers

#come with<stdio.h>
#come with<math.h>
#come with<stdlib.h>
int primary(int argc, char * argv[])
{
if(argc==1){33
printf(“No command line argument provide, upload them first”);
go back 0;
}
double firstNumber, secondNumber, temporaryVariable;
firstNumber = atoi(argv[1]);
secondNumber = atoi(argv[2]);
temporaryVariable = firstNumber;
firstNumber = secondNumber;
secondNumber = temporaryVariable;
printf(“nAfter swapping, firstNumber = %.2lfn”, firstNumber);
printf(“After swapping, secondNumber = %.2lf”, secondNumber);
go back 0;

Most sensible 20 Coding Program Ask In Examination & Interview

Hope You Like This Weblog And You Get Data For Your Examination And Interview Additionally Thank YoU and For Extra Content material Like This Click on Right here Click on Right here

 


Leave a Reply

Your email address will not be published.

Donate Us

X