Assignment 2_ String & Preprocessors in C

 

                                                           Assignments 2

                                       String & Preprocessors in C

1) Which function is used to join two strings? Give syntax.

2) What is macro? Explain the types of macros?

3) Give syntax and use of following functions:

 i) strlen                ii) strcat               iii) strcmp            iv) strcpy              v) strrev

4) What is the use of strcpy() function in C?

5) Demonstrate puts () function

6) What is macro? Write types of preprocessors in C.

7) What is the use of strncat () function.

 8) What is command line argument? Write properties of command line argument.

9) What is the use of # include directive.

10) Explain in brief concept of macros substitution directives.

 11) What is string? Hoe to declare string & initialize.

12) Write a ‘C’ program to accept a string & convert in uppercase without using built - in function.

13) Differentiate macros and functions.

14) Program to concatenate two string in single array.

15) Program to calculate area & circumferences of circle using macro.

16) Explain any three searching function of string.

17) What is string literals?

18) Which Function are used to read string.

19) Write a ‘C’ program to accept a string & copy string without using built - in function.

20) What is the output of following C code? Justify.

 

1) int main ( )

 {

static char name [] = “programming”;

char *s ;

 s = & name [6] - 4;

 while (*s)

printf (“%c”, * s ++);

}

2)

What is the output of following C code? Justify.

 # define Test (x) (x * x)

 int main ( )

 {

int a, b = 3;

a = Test (b + 3);

printf (“% d - % d”, a, b);

 }

4) #include<stdio.h>

int main()

{

int a =5, b=10, c=7;

predict (a,&b,c);

printf("%d - %d - %d",a,b,c);

}

void predict(int p,int *q,int r)

{

p = 50;

*q =*q * 10;

r = 77;

}

5)

# include<stdio.h>

 int main ()

 {

 char str[100];

char *ptr;

 strcpy(str, “India is GREAT”);

 ptr = str + strlen (str);

 printf (“The string is:”);

 while (*ptr ! = str)

printf (“%c”, *ptr --);

return 0;

}

Comments

Popular posts from this blog

Slip 11: Write node js application that transfer a file as an attachment on web and enables browser to prompt the user to download file using express js.

Slip 7 Create a node js file named main.js for event-driven application. There should be a main loop that listens for events, and then triggers a callback function when one of those events is detected.

Slip 1(a) Write an Angular 13 application addition of two numbers using ng-init, ng-model & ng-bind. And also demonstrate ng-show, ng-disabled, ng-click directives on button component.