Tcs - NQT Programming Campus - Funda PDF
Tcs - NQT Programming Campus - Funda PDF
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
if(argc<2)
return -1;
int a,b,side1,side2,side3;
a=atoi(argv[1]);
b=atoi(argv[2]);
side1=pow(a,2);
side2=pow(b,2);
side3=sqrt((side1+side2));
return 0;
ARGUMENTS
#include <stdio.h>
Telegram - https://t.me/camous_funda
int a,b;
int i;
if(argc<2)
return -1;
printf("arg[%2d]: %d\n",i,atoi(argv[i]));
return 0;
integer N. The factorial of a number N is defined as the product of all integers from 1 up
formatted as an integer WITHOUT any other additional text. You may assume that the
input integer will be such that the output will not exceed the largest possible integer that
Example:
Output : 24
The code below takes care of negative numbers but at the end of the page there
Telegram - https://t.me/camous_funda
#include <stdlib.h> // for function atoi() for converting string into int
int fact(int n)
if (n == 0)
return 1;
else {
int ans = 1;
int i;
ans = ans * i;
}
return ans;
if (argc == 1) {
printf("No command line argument exist Please provide them first \n");
return 0;
} else {
int i, n, ans;
n = atoi(argv[i]);
ans = fact(n);
Telegram - https://t.me/camous_funda
printf("%d\n", ans);
return 0;
#include <stdio.h>
int n,i;
n = atol(argv[1]);
factorial *= i;
LINE ARGUMENTS
Telegram - https://t.me/camous_funda
#include<stdio.h>
int num,binary,decimal=0,rem,base=1;
num=atoi(argv[1]);
binary=num;
while(num>0){
rem=num%2;
decimal+=rem*base;
num=num/10;
base=base*2;
printf("%d",decimal);
return 0;
Join campus_funda
#include<stdio.h>
#include<stdlib.h>
int num=atoi(argv[1]);
if(isPalindrome(num))
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
int isPalindrome(int n)
int m=n;
int rev=0;
while(m!=0)
rev=(rev*10) + (m%10);
m=m/10;
Telegram - https://t.me/camous_funda
if(rev==n)
return 1;
else
return 0;
6. Write a C program that will find the sum of all prime numbers in a given range.The
range will be specified as command line parameters. The first command line parameter,
N1 which is a positive integer, will contain the lower bound of the range. The second
command line parameter N2, which is also a positive integer will the upper bound of the
range. The program should consider all the prime numbers within the range, excluding
the upper and lower bound. Print the output in integer format to stdout. Other than the
integer number, no other extra information should be printed to stdout.
#include<stdio.h>
int N1,N2,i,j,sum=0,count,lower,upper;
if(argc!=3)
exit(0);
N1=atoi(argv[1]);
lower=N1+1;
N2=atoi(argv[2]);
upper=N2;
for(i=lower;i<upper;i++)
count=1;
for(j=2;j<=i/2;j++)
if(i%j==0)
count++;
if(count==1)
sum=sum+i;
}
}
printf("%d",sum);
Telegram - https://t.me/camous_funda
return 0;
Telegram - https://t.me/camous_funda