PDF Google Drive Downloader v1.1


Report a problem

Content text TCS NQT Model Programming Coding Questions Paper.pdf

TCS NQT Model Programming/ Coding Questions Paper 1. CALCULATE LENGTH OF THE HYPOTENUSE OF RIGHT ANGLED TRIANGLE #include #include #include int main(int argc, char *argv[]) { if(argc<2) { printf("please use \"prg_name value1 value2 ... \"\n"); 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)); printf("the hypotenuse is %d",side3); return 0; } 2. QUES. SAMPLE PROGRAM TO PRINT ALL INTEGERS USING COMMAND LINE ARGUMENTS // Program to print all value of // command line argument // once we get the value from command // line we can use them to solve our problem #include int main(int argc, char *argv[])
{ int a,b; int i; if(argc<2) { printf("please use \"prg_name value1 value2 ... \"\n"); return -1; } for(i=1; i // for printf
#include // for function atoi() for converting string into int // Function to return fact value of n int fact(int n) { if (n == 0) return 1; else { int ans = 1; int i; for (i = 1; i <= n; i++) { ans = ans * i; } return ans; } } // argc tells the number of arguments // provided+1 +1 for file.exe // char *argv[] is used to store the // command line arguments in the string format int main(int argc, char* argv[]) { // means only one argument exist that is file.exe if (argc == 1) { printf("No command line argument exist Please provide them first \n"); return 0; } else { int i, n, ans; // actual arguments starts from index 1 to (argc-1) for (i = 1; i < argc; i++) { // function of stdlib.h to convert string // into int using atoi() function n = atoi(argv[i]); // since we got the value of n as usual of // input now perform operations // on number which you have required // get ans from function ans = fact(n);

Related document

x
Report download errors
Report content



Download file quality is faulty:
Full name:
Email:
Comment
If you encounter an error, problem, .. or have any questions during the download process, please leave a comment below. Thank you.