Preview

Nt1310 Unit 4

Better Essays
Open Document
Open Document
3614 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Nt1310 Unit 4
1. Point out the error in the following program

main()
{
const char *fun();
*fun()='A';
} const char *fun()
{
return "Hello";
}
Ans. fun() returns to a "const char" pointer which cannot be modified

2. What would be the output of the following program?

main()
{
const int x=5; int *ptrx; ptrx=&x; *ptrx=10; printf("%d",x); }
a) 5 b) 10 c) Error d) Garbage value

3. A switch statement cannot include

a) constants as arguments b) constant expression as arguments
c) string as an argument d) None of the above

4. How long the following program will run?

main()
{
printf("\nSonata Software"); main(); }
a) infinite loop b) until the stack overflows
c) All of the above d) None of the above

5. On combining
…show more content…
The program is trying to collect the value of a "void" function into an integer variable.

7. In the following program how would you print 50 using p?

main()
{
int a[]={10, 20, 30, 40, 50}; char *p; p= (char*) a;
}
Ans. printf("\n%d",*((int*)p+4));

8. Would the following program compile?

main()
{
int
…show more content…
If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output?

main(int argc, char *argv[])
{
int i,j=0; for(i=0;i<argc;i++) j=j+ atoi(argv[i]); printf("%d",j); }
a) 1 2 3 b) 6 c) error d) "123"

13. If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday? What would be the output?

main(int argc, char *argv[])
{
while(--argc >0) printf("%s",*++argv); }
a) myprog monday tuesday wednesday thursday b) monday tuesday wednesday thursday
c) myprog tuesday thursday d) None of the above

14. In the following code, is p2 an integer or an integer pointer?

typedef int* ptr ptr p1,p2;
Ans. Integer pointer

15. If the following program (myprog) is run from the command line as myprog friday tuesday sunday, What would be the output?

main(int argc, char *argv[])
{
while(sizeofargv) printf("%s",argv[--sizeofargv]); }
a) myprog friday tuesday sunday b) myprog friday tuesday
c) sunday tuesday friday myprog d) sunday tuesday friday

16. What would be the output of the following program?

main()
{
int i=4;

You May Also Find These Documents Helpful

  • Good Essays

    Nt1310 Unit 4

    • 313 Words
    • 2 Pages

    1) Block B in Fig. 6-31 weighs 603 N. The coefficient of static friction between block and table is 0.32; angle θ is 33°; assume that the cord between B and the knot is horizontal. Find the maximum weight of block A for which the system will be stationary.…

    • 313 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Nt1310 Unit 4

    • 775 Words
    • 4 Pages

    Part III PHYSICS HSE II Time:2Hours Max:60 Scores 1. Three identical charges each +q are placed at the corners of an equilateral triangle of side d cm. Calculate the force on a +ive charge +2q at the centroid of the triangle. 2 2.If the earth is supposed to be a metallic sphere,its capacity will be nearly (a) 700pf (b) 700 microfarad (c) 700f (d) 6.4 X10^6 f 1score 3. write the relation between dielectric constant and electric susceptibility. 1score 4. A box encloses an electric dipole consisting of charge 5micro C and -5micro C and of length 10cm. What is the total electric flux through the box? 2scores 5. Find the ratio of the p.d that must be applied across the (1)parallel (2) series combination of two identical capacitors so that the energy stored in the two cases becomes the same. 2 scores 6.(a)…

    • 775 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    Nt1310 Unit 5

    • 368 Words
    • 2 Pages

    the ratio of resistors on one side of the bridge is one while the ratio of resistors on the other side is infinity…

    • 368 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 6

    • 297 Words
    • 2 Pages

    8. The reactance offered by a capacitor to alternating current of frequency 50 Hz is 20 Q. If frequency is increased to 100 Hz, then reactance becomes -----------------.…

    • 297 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    The expression 1 To 5 in the Case 1 To 5 clause specifies the range of numbers from ____.…

    • 595 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    E-Commerce Exercise

    • 1068 Words
    • 5 Pages

    3. The String class ____ method evaluates the contents of two String objects to determine if they are equivalent.…

    • 1068 Words
    • 5 Pages
    Better Essays
  • Satisfactory Essays

    4. Build the Program using build option and check for any errors (correct if any) (this step generates a source file with extension .s19).…

    • 328 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Woooo!

    • 982 Words
    • 4 Pages

    #include <stdlib.h> #include <stdio.h> #include <string.h> #include "dynamicArray.h" #include <assert.h> /* param: s the string * param: num a pointer to double * returns: true (1) if s is a number else 0 or false. * postcondition: if it is a number, num will hold *…

    • 982 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Homeos

    • 369 Words
    • 2 Pages

    Write a shell-like program that illustrates how LINUX spawns processes. This simple program will provide its own prompt to the user, read the command from the input and execute the command. It is sufficient to handle just argument-less commands, such as ls and date.…

    • 369 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Hi Everyone.

    • 326 Words
    • 2 Pages

    * You have to tell the computer, step by step, exactly what you want it to do. The computer then “executes" the program, following each step to accomplish the end goal.…

    • 326 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Pointer and Stack

    • 1257 Words
    • 6 Pages

    Here, type is the pointer's base type; it must be a valid C data type and var-name is the name of the pointer variable. The asterisk * you used to declare a pointer is the same asterisk that you use for multiplication. However, in this statement the asterisk is being used to designate a variable as a pointer. Following are the valid pointer declaration:…

    • 1257 Words
    • 6 Pages
    Better Essays
  • Powerful Essays

    1. a. The PC contains 300, the address of the first instruction. This value is loaded…

    • 15908 Words
    • 64 Pages
    Powerful Essays
  • Good Essays

    Compiler Construction

    • 376 Words
    • 3 Pages

    Interpreter-a program that reads an executable program and produces the results of running that program…

    • 376 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Tets

    • 2487 Words
    • 10 Pages

    • The CPU executes one instruction of the process after another, until the process is complete. At most one instruction is executed on behalf of the process. Therefore, although two processes may be associated with the same program, they are nevertheless considered two separate execution sequences. It is common to have a program that spawns many processes as it runs.…

    • 2487 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    /Contiguous file allocation/ #include<stdio.h> Int main() { char a[10][10]; int I,flb[10],sb[10]; for(i=1;i<=5;i++) { printf(“\nEnter the file name:”); scanf(“%s”,&a); printf(“\nEnter the starting block:”); scanf(“%d”,&sb[i]); printf(“\nEnter the file length in blocks:”); scanf(“%d”,&flb[i]); } printf(“\n\nList of files\tstarting block\tfile length”); for(i=0;i<5;i++) { printf(“\n%s\t%d\t%d”,a[i],sb[i],flb[i]); } return 1; } /indexed allocation/ #include<stdio.h> int main() { char a[10]; int i,1.b,a.b[10]; srintf(“\nEnter the file name:”); Scanf(“%d”,&a); printf(“\n\nIndexed block:”); scanf(“%”,&ib); for(i=1;i<5;i++){ printf(“\nEnter the child of index block%d:”,i); scanf(“%d”,&c I b[i]); } printf(“\n\n\nThe list of files\t index block”); printf(“\n\n%s\t%d”,a,ib); printf(“\n\nThe above file utilization index block of child following!\n\n\t”); for(i=1;i<=5;i++){ printf(“%d\t”,c I b[i]); } return 1; } /linked allocation/ #include<stdio.h>…

    • 317 Words
    • 2 Pages
    Good Essays