c Programming

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The position of 'i' is: 19

#include <string.h> #include <stdio.h> int main(void) { char text[] = "I learn through IndiaBIX.com"; char *ptr, c = 'i'; ptr = strrchr(text, c); if (ptr) printf("The position of '%c' is: %d\n", c, ptr-text); else printf("The character was not found\n"); return 0; }

It prints ASCII value of the binary number present in the first byte of a float variable a.

#include<stdio.h> int main() { float a=3.14; char *j; j = (char*)&a; printf("%d\n", *j); return 0; }

Error: ptr must be type of va_list

#include<stdio.h> #include<stdarg.h> void varfun(int n, ...); int main() { varfun(3, 7, -11.2, 0.66); return 0; } void varfun(int n, ...) { float *ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num); }

c = 7

#include<stdio.h> int add(int, int); /* Function prototype */ int main() { int a = 4, b = 3, c; c = add(a, b); printf("c = %d\n", c); return 0; } int add(int a, int b) { /* returns the value and control back to main() function */ return (a+b);

No

#include<stdio.h> int main() { int a=10, *j; void *k; j=k=&a; j++; k++; printf("%u %u\n", j, k); return 0; }

30

#include<stdio.h> int main() { int k, num=30; k = (num>5 ? (num <=10 ? 100 : 200): 500); printf("%d\n", num); return 0; }

2, 3

#include<stdio.h> int main() { int x = 10, y = 100%90, i; for(i=1; i<10; i++) if(x != y); printf("x = %d y = %d\n", x, y); return 0; } 1 : The printf() function is called 10 times. 2 : The program will produce the output x = 10 y = 10 3 : The ; after the if(x!=y) will NOT produce an error. 4 : The program will not produce output.

Floating point formats not linked (Run time error)

#include<stdio.h> int main() { struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0; i<=9; i++) scanf("%s %f", e[i].name, &e[i].sal); return 0; }

False

Bit fields CANNOT be used in union.

1, 4, 4

If char=1, int=4, and float=4 bytes size, What will be the output of the program ? #include<stdio.h> int main() { char ch = 'A'; printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f)); return 0; }

False

The first argument to be supplied at command-line must always be count of total arguments.

return

The keyword used to transfer control from a function back to the calling function is

strrchr()

The library function used to find the last occurrence of a character in a string is

Error: Declaration missing ';'

typedef struct data; { int x; sdata *b; }sdata;

True

va_list is an array that holds information needed by va_arg and va_end

Error

What will be the output of the program ? #include<stdio.h> int main() { char str[] = "Nagpur"; str[0]='K'; printf("%s, ", str); str = "Kanpur"; printf("%s", str+1); return 0; }

12, 12, 12

What will be the output of the program ? #include<stdio.h> int main() { int i=4, j=8; printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j); return 0; }

12480

What will be the output of the program? #include<stdio.h> int main() { char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1; } return 0; }

stdarg.h

Which header file should you include, if you are going to develop a function, which can accept variable number of arguments?

The code counts number of lines in the file

Which of the following statement is correct about the program? #include<stdio.h> int main() { FILE *fp; char ch; int i=1; fp = fopen("myfile.c", "r"); while((ch=getc(fp))!=EOF) { if(ch == '\n') i++; } fclose(fp); return 0; }

1,4

Which of the following statements are correct about an array? 1: The array int num[26]; can store 26 elements. 2: The expression num[1] designates the very first element in the array. 3: It is necessary to initialize the array at the time of declaration. 4: The declaration num[SIZE] is allowed if SIZE is a macro.

The function calculates the factorial value of an integer

long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; }


संबंधित स्टडी सेट्स

Research Methods Learning Outcomes

View Set

USING GIBBS FREE ENERGY TO PREDICT SPONTANEOUS REACTIONS

View Set

N436 Evidence Based Practice EAQ

View Set

Chapter 6. Data: Business Intelligence

View Set

NSG 330 Ch 36- Management Immune Deficiency Disorders

View Set